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

IOU - Currency in the amount editor is USD when the request is created in local currency #40543

Closed
6 tasks done
izarutskaya opened this issue Apr 19, 2024 · 19 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2

Comments

@izarutskaya
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.63-5
Reproducible in staging?: Y
Reproducible in production?: N
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to 1:1 DM.
  3. Create a manual request in local currency.
  4. Go to transaction thread.
  5. Click Amount.

Expected Result:

The currency in Amount editor should be the local currency,.

Actual Result:

The currency in Amount editor is USD, when the request is created in local currency.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6454383_1713498999553.20240419_115228.mp4

View all open jobs on GitHub

@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 19, 2024
Copy link

melvin-bot bot commented Apr 19, 2024

Triggered auto assignment to @Beamanator (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Apr 19, 2024

Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Apr 19, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@izarutskaya
Copy link
Author

@joekaufmanexpensify I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@izarutskaya
Copy link
Author

We think this issue might be related to the #collect project.

@izarutskaya
Copy link
Author

Production

bandicam.2024-04-19.07-21-56-741.mp4

@nkdengineer
Copy link
Contributor

Proposal

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

The currency in Amount editor is USD, when the request is created in local currency.

What is the root cause of that problem?

We're passing wrong transaction data to get the currency here. we should pass it as transaction when we're editing instead of draftTransaction

const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction) ?? {currency: CONST.CURRENCY.USD};

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

Update this line to

const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? transaction : draftTransaction) ?? {currency: CONST.CURRENCY.USD};

const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction) ?? {currency: CONST.CURRENCY.USD};

What alternative solutions did you explore? (Optional)

NA

@joekaufmanexpensify
Copy link
Contributor

Seems like a legit bug. I could see this being a legit blocker. @Beamanator you agree?

@Beamanator
Copy link
Contributor

Oof ya i would say this is a blocker, it's not great to show it's $100 when it's actually 100 in some other currency 😬

@Beamanator
Copy link
Contributor

Beamanator commented Apr 19, 2024

Hmm this one looks pretty sus: #38892

cc @roryabraham @sobitneupane @bernhardoj

@Beamanator
Copy link
Contributor

Beamanator commented Apr 19, 2024

Posted in slack & tagged ^ those people - https://expensify.slack.com/archives/C01GTK53T8Q/p1713538343234679?thread_ts=1713521084.907369&cid=C01GTK53T8Q

Sadly I'm unable to quickly revert the PR to test, probably b/c the PR was started a while ago

@bernhardoj
Copy link
Contributor

Hmm, based on @nkdengineer root cause and solution which I already tested, it shouldn't be coming from our PR because we don't change the isEditing ? draftTransaction : transaction code/logic.

image

@bernhardoj
Copy link
Contributor

I think it's coming from #39144. In amount page, we are creating a backup transaction if we are editing a money request.

useEffect(() => {
if (!isEditing) {
return;
}
// A temporary solution to not prevent users from editing the currency
// We create a backup transaction and use it to save the currency and remove this transaction backup if we don't save the amount
// It should be removed after this issue https://github.com/Expensify/App/issues/34607 is fixed
TransactionEdit.createBackupTransaction(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction);

createBackupTransaction will take the current transaction data and copy it to transactionsDraft, but the PR above changes the name to transactionsBackup.

That's why when we are editing, we pass the draftTransaction instead of transaction to get the data from the backup data.

const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction) ?? {currency: CONST.CURRENCY.USD};

Rename the key to transactionsBackup and the issue is fixed.

draftTransaction: {
key: ({route}) => {
const transactionID = route.params.transactionID ?? 0;
return `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`;

ONYXKEYS.COLLECTION.TRANSACTION_BACKUP

@Beamanator
Copy link
Contributor

Thanks @bernhardoj ! I agree it does look like #39144 is the real culprit - they modified createBackupTransaction which now updates a new onyx key, and they didn't look where else that function was used & if we needed to subscribe to the new onyx key there (which it looks like we do need to)

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Hourly KSv2 labels Apr 19, 2024
@Beamanator
Copy link
Contributor

Ok I have a PR up for the fix - note I used @bernhardoj 's solution

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Apr 19, 2024
@thienlnam thienlnam removed the DeployBlockerCash This issue or pull request should block deployment label Apr 20, 2024
Copy link

melvin-bot bot commented Apr 20, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@shahinyan11
Copy link

shahinyan11 commented Apr 20, 2024

My proposal will cover this issue . @Beamanator please take a look

@DylanDylann
Copy link
Contributor

DylanDylann commented Apr 21, 2024

@Beamanator @allroundexperts The new field ONYXKEYS.COLLECTION.TRANSACTION_BACKUP should only be used in distance requests as explained here. With the manual request, we should use draftTransaction as before.

cc @mountiny @bernhardoj

@joekaufmanexpensify
Copy link
Contributor

@DylanDylann I see you were already paid for this PR in #40631 (comment), so I don't think any payment is due here. Closing this out for now, but LMK if you think that is not correct!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants