You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[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
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
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?
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
we can create a hook withIOU where we listen for such changes and update the iou accordingly
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)
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.
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.
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
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[/+]on Aug 14, 2023
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Aug 10, 2023
Triggered auto assignment to @sonialiap (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Aug 10, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)ygshbht commentedon 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
USDregardless 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 thecurrentUserPersonalDetailswhen theresetMoneyRequestInfofunction 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 defaultIOUcurrency,USD.What changes do you think we should make in order to solve the problem?
Update
We need to ensure that
IOU.currencyis in sync withcurrentUserPersonalDetails.currency. We can listen to changes incurrentUserPersonalDetails.currencyand updateIOU.currencyaccordingly if user has logged in the session. So instead of directly gettingiouApp/src/pages/iou/steps/NewRequestAmountPage.js
Line 200 in fb57c17
we can create a hook
withIOUwhere we listen for such changes and update the iou accordinglyUseEffect Approach: In the
NewRequestAmountPage, use auseEffecthook to callresetMoneyRequestInfoor only updatecurrencywhen the component mounts/currentUserPersonalDetails.currencyupdates ifnavigateToNextPagehasn'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)
resetMoneyRequestInfo/ currency change function at a higher-level component that mounts when the user logs in and once thecurrentUserPersonalDetailshave been received. This ensures that the default currency is always in sync whenever the user logs in.Example URL: https://staging.new.expensify.com/request/new/confirmation/?currency=INR
App/src/pages/iou/steps/NewRequestAmountPage.js
Lines 121 to 123 in fb57c17
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
sonialiap commentedon Aug 14, 2023
I think we can simplify the reproduction steps a bit:
[-]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[/+]melvin-bot commentedon Aug 14, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01aad4c8cddaf2f5c5
melvin-bot commentedon Aug 14, 2023
Current assignee @sonialiap is eligible for the External assigner, not assigning anyone new.
79 remaining items
sonialiap commentedon Oct 23, 2023
I've submitted a refund request to @tienifr and updated the amounts in comment #24393 (comment)
sonialiap commentedon Oct 23, 2023
@allroundexperts please make a request in ND for $500
allroundexperts commentedon Oct 23, 2023
All done @sonialiap!
JmillsExpensify commentedon Oct 24, 2023
$500 payment approved for @allroundexperts based on comment above.
melvin-bot commentedon Oct 27, 2023
@anmurali, @sonialiap, @cristipaval, @allroundexperts, @tienifr Whoops! This issue is 2 days overdue. Let's get this updated quick!
cristipaval commentedon Oct 27, 2023
Are we good to close this one, @sonialiap?
sonialiap commentedon Oct 30, 2023
The last remaining step is following up on the refund. But I can sort that out with the issue being closed. Closing
tienifr commentedon Nov 1, 2023
@sonialiap I've refunded, thanks!
sonialiap commentedon Nov 3, 2023
Thanks, @tienifr 🙇