Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2023-10-10] [HOLD for payment 2023-10-09] [$1000] Web - Request money - Request confirmation link automatically changes request money currency to USD #24393

Closed
1 of 6 tasks
izarutskaya opened this issue Aug 10, 2023 · 57 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Aug 10, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

Precondition: Your default currency should not be USD when you click on request money

  1. Open the app
  2. Click on plus and click on request money
  3. Enter any amount and continue, select any user and continue
  4. Copy the URL, link should look like: https://staging.new.expensify.com/request/new/confirmation/
  5. Logout and paste the URL
  6. Login and observe that now currency is changed to USD even though your default currency is different and was not changed during last request

Expected Result:

App should display default currency of user in request money when we open confirmation link on login

Actual Result:

App displays USD as currency in request money when we open confirmation link on login

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: v1.3.53-1

Reproducible in staging?: Y

Reproducible in production?: Y

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

currency.changes.to.USD.in.confirmation.link.mp4
Recording.1164.mp4

Expensify/Expensify Issue URL:

Issue reported by: @dhanashree-sawant

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1691057407426539

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01aad4c8cddaf2f5c5
  • Upwork Job ID: 1691154081471135744
  • Last Price Increase: 2023-08-21
  • Automatic offers:
    • tienifr | Contributor | 26271380
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 10, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

Triggered auto assignment to @sonialiap (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 10, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@ygshbht
Copy link
Contributor

ygshbht commented Aug 10, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Upon refreshing the Request Money confirmation link, the displayed currency defaults to USD regardless of the user's set default currency.

What is the root cause of that problem?

The default currency for IOUs is USD. When the user initiates the Request Money flow, the currency is updated based on the currentUserPersonalDetails when the resetMoneyRequestInfo function is invoked. However, when the user refreshes the page, the personal details have not yet been set and the function responsible for updating this, which is triggered by FAB -> Request Money, isn't called. As a result, the app falls back to the default IOU currency, USD.

What changes do you think we should make in order to solve the problem?

Update

  1. We need to ensure that IOU.currency is in sync with currentUserPersonalDetails.currency. We can listen to changes in currentUserPersonalDetails.currency and update IOU.currency accordingly if user has logged in the session. So instead of directly getting iou

    iou: {key: ONYXKEYS.IOU},

    we can create a hook withIOU where we listen for such changes and update the iou accordingly

  2. UseEffect Approach: In the NewRequestAmountPage, use a useEffect hook to call resetMoneyRequestInfo or only update currency when the component mounts/ currentUserPersonalDetails.currency updates if navigateToNextPage hasn't been called yet and user has signed in in the session. This ensures that even if the page is refreshed, the correct default currency is always displayed.

What alternative solutions did you explore? (Optional)

  1. Global Approach: A more global solution would be to invoke the resetMoneyRequestInfo/ currency change function at a higher-level component that mounts when the user logs in and once the currentUserPersonalDetails have been received. This ensures that the default currency is always in sync whenever the user logs in.
  2. URL Storage: Store the currency in the URL itself. This means that regardless of any refreshing or subsequent navigation, the currency remains persistent as it's directly encoded in the URL.
    Example URL: https://staging.new.expensify.com/request/new/confirmation/?currency=INR
  3. Modify Reset Conditions: Update the shouldReset condition in the NewRequestAmountPage to account for situations where the page might be refreshed, ensuring the correct currency is displayed.
    if (shouldReset) {
    IOU.resetMoneyRequestInfo(moneyRequestID);
    }

I'd choose URL storage for IOU urls as the preferred solution as it seems to present no drawbacks while others could due to the way the app is configured

Other areas facing this issue, could also use a similar approach

@melvin-bot melvin-bot bot added the Overdue label Aug 14, 2023
@sonialiap
Copy link
Contributor

sonialiap commented Aug 14, 2023

I think we can simplify the reproduction steps a bit:

  1. Log into an account and set the currency to something not USD (ex: EUR)
  2. Click on the FAB > Request Money
  3. Confirm the OUI screen shows the default currency (ex: EUR). Exit IOU set up without saving
  4. Click on https://staging.new.expensify.com/request/new/confirmation/
  5. Confirm that the OUI screen shows USD instead of your default currency

@melvin-bot melvin-bot bot removed the Overdue label Aug 14, 2023
@sonialiap sonialiap added the External Added to denote the issue can be worked on by a contributor label Aug 14, 2023
@melvin-bot melvin-bot bot changed the title Web - Request money - Request confirmation link automatically changes request money currency to USD [$1000] Web - Request money - Request confirmation link automatically changes request money currency to USD Aug 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01aad4c8cddaf2f5c5

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

Current assignee @sonialiap is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Aug 14, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External)

@allroundexperts
Copy link
Contributor

@thesahindia is OOO and will be back on 19th. I can jump in here if needed.

@tienifr
Copy link
Contributor

tienifr commented Aug 15, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Web - Request money - Request confirmation link automatically changes request money currency to USD

What is the root cause of that problem?

When users click on Request Money or Send Money or Split Bill, we call IOU.startMoneyRequest, in this function we request money request info to local currency. And we don't want to update this value when users refresh page

Unfortunately, in this case after users login successfully, we don't have the login to set currency, so the default currency(USD) is returned

What changes do you think we should make in order to solve the problem?

We should't listen the currentUserPersonalDetails change in NewRequestAmountPage, if we do that we have to do the same thing in other places (MoneyRequestDescriptionPage,...). And the pages have to re-render whenever currentUserPersonalDetails get changed.

That why I suggest we should fix this problem in IOU.js

In this file we already listen currentUserPersonalDetails change, so we just need to init iou currency after users login successfully. We can detect users login by using SessionUtils.didUserLogInDuringSession()

let shouldResetIOUAfterLogin = true; // add this variable

let currentUserPersonalDetails = {};
Onyx.connect({
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    callback: (val) => {
        currentUserPersonalDetails = lodashGet(val, userAccountID, {});
        if(val && SessionUtils.didUserLogInDuringSession() && shouldResetIOUAfterLogin){
            resetMoneyRequestInfo();
            shouldResetAfterLogin = false
        }
    },
});

Note: This approach may need some times to load the personalDetails so the $ symbol will be shown for a moment before showing the local currency. We can hide the currency (or showing the skeleton) before loading the local currency. In order to archive that we can set didInitCurrency: true in ONYX.IOU when execute above logic ^

Result

Screen.Recording.2023-08-15.at.12.23.21.mov

@ygshbht
Copy link
Contributor

ygshbht commented Aug 15, 2023

@tienifr nicely elaborates the third point I mentioned
Global Approach: A more global solution would be to invoke the resetMoneyRequestInfo/ currency change function at a higher-level component that mounts when the user logs in and once the currentUserPersonalDetails have been received. This ensures that the default currency is always in sync whenever the user logs in.

However, the issue with this approach is that we still see the $ for some time after page refresh. We need to combine this approach with the URL approach to provide a more robust solution

2023-08-15.13-00-05.mp4

ygshbht@a653b5f

@melvin-bot melvin-bot bot added the Overdue label Aug 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@thesahindia
Copy link
Member

@allroundexperts, feel free to review the proposals. I am not at my 100%

@melvin-bot melvin-bot bot removed the Overdue label Aug 21, 2023
@thesahindia thesahindia removed their assignment Aug 21, 2023
@allroundexperts
Copy link
Contributor

Thanks for your proposal @ygshbht.
I think your main solution would require us to use the logic in every component as highlighted by @tienifr. The alternate solution you mentioned here I think is too generic and is completely missing the implementation detail.

I don't think your 4th solution would work because a user might not add the currency as a query parameter to the url. In that case, we should default to the users default currency which again would be undefined for some time.

@tienifr Your proposal has all the necessary implementation details. I think we should show a loader until the currency loads.

@tienifr's proposal looks good to me.

🎀 👀 🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

Triggered auto assignment to @cristipaval, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@allroundexperts
Copy link
Contributor

@sonialiap Can you please assign this to me as @thesahindia un-assigned themselves?

@ygshbht
Copy link
Contributor

ygshbht commented Aug 21, 2023

Thanks for your proposal @ygshbht. I think your main solution would require us to use the logic in every component as highlighted by @tienifr. The alternate solution you mentioned here I think is too generic and is completely missing the implementation detail.

I don't think your 4th solution would work because a user might not add the currency as a query parameter to the url. In that case, we should default to the users default currency which again would be undefined for some time.

@tienifr Your proposal has all the necessary implementation details. I think we should show a loader until the currency loads.

@tienifr's proposal looks good to me.

🎀 👀 🎀 C+ reviewed

That's a very wise decision indeed.

I'd like to add some clarifications.

I don't think your 4th solution would work because a user might not add the currency as a query parameter to the url. In that case, we should default to the users default currency which again would be undefined for some time.

User manually editing the URL is not specific to this issue. They can do that for any URL at their own risk. However, if they navigate using the URL provided by the app, they won't face the isssue. We can only fix what's in our control.

I think your main solution would require us to use the logic in every component as highlighted by @tienifr. The alternate solution you mentioned #24393 (comment) I think is too generic and is completely missing the implementation detail.

Yes, it is missing the implementation details. I said we need to "invoke the resetMoneyRequestInfo/ currency change function at a higher-level component that mounts when the user logs in and once the currentUserPersonalDetails have been received" and @tienifr provided the code for it. If @tienifr 's proposal is selected because he focused on one solution and provided the code for it and my other solution of URL editing, even though better for end user, increases code complexity by making changes to several files, the decision won't be wrong indeed.

@allroundexperts
Copy link
Contributor

allroundexperts commented Aug 21, 2023

@ygshbht You don't need to include every tiny detail but at the same time, you shouldn't propose an alternate solution this abstract.

I'd leave the final call to @cristipaval!

@sonialiap
Copy link
Contributor

Thanks!

@sonialiap
Copy link
Contributor

sonialiap commented Oct 15, 2023

@allroundexperts review, no bonus because of regression = $500 - please request in NewDot
@tienifr fix, no bonus because of regression = $1000 - paid ✔️ should be $500, refund requested
@dhanashree-sawant report = $250 - paid ✔️

@melvin-bot melvin-bot bot added the Overdue label Oct 17, 2023
@sonialiap
Copy link
Contributor

@allroundexperts please complete the checklist :)

@melvin-bot melvin-bot bot removed the Overdue label Oct 17, 2023
@sonialiap sonialiap added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Oct 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 17, 2023

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@Expensify Expensify deleted a comment from melvin-bot bot Oct 17, 2023
@sonialiap
Copy link
Contributor

I'm OOO Oct 16-23. Adding leave buddy

Status: waiting for Sibtain to complete the checklist

@allroundexperts
Copy link
Contributor

@sonialiap I think it should be $500 for me and @tienifr. We pay no bonus + 50% penalty for regressions.

@allroundexperts
Copy link
Contributor

Checklist

  1. I couldn't find any particular PR which caused this issue. This seemed to have never been thought off when implementing the request money page.
  2. N/A
  3. https://expensify.slack.com/archives/C049HHMV9SM/p1697574239538219
  4. Regression test would be helpful.

Regression test steps

  1. Login and make sure that the default currency of the user is other than the USD.
  2. Click on plus icon in the LHN and click on request money.
  3. Enter any amount and continue, select any user and continue.
  4. Copy the URL of the confirmation screen and Logout.
  5. Open the copied url and login and verify that the currency that shows up remains the same as the default currency of the user.

Do we 👍 or 👎 ?

@melvin-bot melvin-bot bot added the Overdue label Oct 20, 2023
@sonialiap
Copy link
Contributor

sonialiap commented Oct 23, 2023

Back from OOO

Thanks for completing the checklist!

Ah, you're right. I tried looking up regression policy in the SO but either I was looking at an old post or missed this bit. I'll check with the team on what to do in this case since I've already made the payments in Upwork (idk the status of the ND payment).

image

@melvin-bot melvin-bot bot removed the Overdue label Oct 23, 2023
@sonialiap
Copy link
Contributor

I've submitted a refund request to @tienifr and updated the amounts in comment #24393 (comment)

@sonialiap
Copy link
Contributor

@allroundexperts please make a request in ND for $500

@allroundexperts
Copy link
Contributor

All done @sonialiap!

@JmillsExpensify
Copy link

$500 payment approved for @allroundexperts based on comment above.

@melvin-bot melvin-bot bot added the Overdue label Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 27, 2023

@anmurali, @sonialiap, @cristipaval, @allroundexperts, @tienifr Whoops! This issue is 2 days overdue. Let's get this updated quick!

@cristipaval
Copy link
Contributor

Are we good to close this one, @sonialiap?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 27, 2023
@sonialiap
Copy link
Contributor

The last remaining step is following up on the refund. But I can sort that out with the issue being closed. Closing

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@tienifr
Copy link
Contributor

tienifr commented Nov 1, 2023

I've submitted a refund request to @tienifr and updated the amounts in comment #24393 (comment)

@sonialiap I've refunded, thanks!

@sonialiap
Copy link
Contributor

Thanks, @tienifr 🙇

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants