Skip to content

[Due for payment 2025-11-18] [$250] Report-Wrong currency at company spend after add unreported different currency with wp #73192

Closed

Description

@nlemma

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


Version Number: v9.2.36-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1425/folder/13176730/41237114/965872675
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Win 11/Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • In self DM create 2 manual expenses with local currency (different USD)
  • Create a workspace, set currency is USD and go to this workspace create a manual expense
  1. Open https://staging.new.expensify.com
  2. Navigate to workspace chat at precondition
  3. Click on manual expense
  4. Click on More
  5. Click on Add expense
  6. Click on Add unreported expense
  7. Add 2 manual expenses in self DM
  8. Click Add to report
  9. Observe Company spend

Expected Result:

Company spend should display correct currency or exchange the money from local currency to USD

Actual Result:

Company spend change the local currency to USD without exchange the money to USD

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6981204_1761123784440.Recording__1380.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021981781505850640746
  • Upwork Job ID: 1981781505850640746
  • Last Price Increase: 2025-10-24
Issue OwnerCurrent Issue Owner: @roryabraham

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 22, 2025
  2. melvin-bot commented on Oct 22, 2025

    @melvin-bot

    Triggered auto assignment to @abekkala (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.

  3. bernhardoj commented on Oct 22, 2025

    @bernhardoj
    Contributor

    Proposal

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

    The money request spend breakdown shows wrong amount information when adding unreported expense with different currency.

    What is the root cause of that problem?

    When we add an unreported expense, it will be added to the nonReimbursableTotal and total which will show the spend breakdown.

    if (reportID && newReport) {
    updatedReportTotals[targetReportID] = (updatedReportTotals[targetReportID] ? updatedReportTotals[targetReportID] : (newReport.total ?? 0)) - transactionAmount;
    updatedReportNonReimbursableTotals[targetReportID] =
    (updatedReportNonReimbursableTotals[targetReportID] ? updatedReportNonReimbursableTotals[targetReportID] : (newReport.nonReimbursableTotal ?? 0)) -
    (transactionReimbursable ? 0 : transactionAmount);
    updatedReportUnheldNonReimbursableTotals[targetReportID] =
    (updatedReportUnheldNonReimbursableTotals[targetReportID] ? updatedReportUnheldNonReimbursableTotals[targetReportID] : (newReport.unheldNonReimbursableTotal ?? 0)) -
    (transactionReimbursable && !isOnHold(transaction) ? 0 : transactionAmount);

    However, the unreported expense has a different currency and we still add it to the report total, but when the API request is done, BE returns the correct total amount, which in turns causes the out-of-pocket amount to be negative. From the OP example, the expense report has a $ currency, a total of $1. Then adds VND 5 of unreported expenses to the report.

    The report total is optimistically updated to $6 and the nonReimbursableTotal is updated to $5.
    Out-of-pocket spend = total - nonReimbursableTotal = $1

    const reimbursableSpend = totalDisplaySpend - nonReimbursableSpend;

    When the API success, BE updates the total back to $1.
    Out-of-pocket spend = total - nonReimbursableTotal = $-4

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

    We need to optimistically calculate the report total only if the currency is the same, just like we did when requesting money in a normal way.

    App/src/libs/actions/IOU.ts

    Lines 3455 to 3467 in 815c92f

    if (iouReport?.currency === currency) {
    if (!Number.isNaN(iouReport.total) && iouReport.total !== undefined) {
    // Use newReportTotal in scenarios where the total is based on more than just the current transaction, and we need to override it manually
    if (newReportTotal) {
    iouReport.total = newReportTotal;
    } else {
    iouReport.total -= amount;
    }
    if (!reimbursable) {
    iouReport.nonReimbursableTotal = (iouReport.nonReimbursableTotal ?? 0) - amount;
    }
    }

    We need to fix this for both the old and new report.

    if (oldReport) {
    updatedReportTotals[oldReportID] = (updatedReportTotals[oldReportID] ? updatedReportTotals[oldReportID] : (oldReport?.total ?? 0)) + transactionAmount;
    updatedReportNonReimbursableTotals[oldReportID] =
    (updatedReportNonReimbursableTotals[oldReportID] ? updatedReportNonReimbursableTotals[oldReportID] : (oldReport?.nonReimbursableTotal ?? 0)) +
    (transaction?.reimbursable ? 0 : transactionAmount);
    updatedReportUnheldNonReimbursableTotals[oldReportID] =
    (updatedReportUnheldNonReimbursableTotals[oldReportID] ? updatedReportUnheldNonReimbursableTotals[oldReportID] : (oldReport?.unheldNonReimbursableTotal ?? 0)) +
    (transaction?.reimbursable && !isOnHold(transaction) ? 0 : transactionAmount);
    }
    if (reportID && newReport) {
    updatedReportTotals[targetReportID] = (updatedReportTotals[targetReportID] ? updatedReportTotals[targetReportID] : (newReport.total ?? 0)) - transactionAmount;
    updatedReportNonReimbursableTotals[targetReportID] =
    (updatedReportNonReimbursableTotals[targetReportID] ? updatedReportNonReimbursableTotals[targetReportID] : (newReport.nonReimbursableTotal ?? 0)) -

    const transactionCurrency = getCurrency(transaction);
    
    if (oldReport && transactionCurrency === oldReport.currency) {
        ...
    }
    if (reportID && newReport && transactionCurrency === newReport.currency) {
        ...
    }
    
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 24, 2025
  5. changed the title [-]Report-Wrong currency at company spend after add unreported different currency with wp[/-] [+][$250] Report-Wrong currency at company spend after add unreported different currency with wp[/+] on Oct 24, 2025
  6. melvin-bot commented on Oct 24, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 24, 2025
  8. melvin-bot commented on Oct 24, 2025

    @melvin-bot

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

  9. jayeshmangwani commented on Oct 27, 2025

    @jayeshmangwani
    Contributor

    @bernhardoj 's proposal #73192 (comment) makes sense and works well - let’s go with it.

    🎀 👀 🎀 C+ reviewed

  10. 13 remaining items

  11. melvin-bot commented on Nov 11, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.48-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-11-18. 🎊

    For reference, here are some details about the assignees on this issue:

  12. melvin-bot commented on Nov 11, 2025

    @melvin-bot

    @jayeshmangwani / @bernhardoj The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  13. abekkala commented on Nov 17, 2025

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR NOV 18

    • Fix: @bernhardoj [$250, if no regressions] payment via NewDot
    • PR Review: @jayeshmangwani [$250, if no regressions]payment via NewDot
      please complete checklist
  14. bernhardoj commented on Nov 18, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  15. abekkala commented on Nov 18, 2025

    @abekkala
    Contributor

    @jayeshmangwani can you complete the checklist so we can close this one out? Thanks!

  16. jayeshmangwani commented on Nov 20, 2025

    @jayeshmangwani
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: feat: reimbursable features #68581 (comment)

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not that CRITICAL

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal

    Preconditions:
    - In self DM create a manual expenses with local currency (different than USD)
    - Create a workspace, set currency to USD, go to this workspace chat, and create a manual expense

    Steps

    1. Open the expense report
    2. Press More at the header > Add expense > Add unreported expense
    3. Add the unreported expense
    4. Verify the unreported expense amount is not added to the report total (it'll only be added after the conversion done by the BE)

    Do we agree 👍 or 👎

  17. jayeshmangwani commented on Nov 20, 2025

    @jayeshmangwani
    Contributor

    Apologies for the delay @abekkala , I’ve completed the checklist.

  18. garrettmknight commented on Nov 21, 2025

    @garrettmknight
    Contributor

    $250 approved for @bernhardoj

  19. abekkala commented on Nov 21, 2025

    @abekkala
    Contributor

    posting summary once more for easier visibility:

    PAYMENT SUMMARY FOR NOV 18

  20. trjExpensify commented on Dec 3, 2025

    @trjExpensify
    Contributor

    approved $250 for @jayeshmangwani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions