Skip to content

[Due for payment 2026-04-01] [Due for payment 2026-03-31] [RCA #83896] Expense - Negative amount is changed to positive amount after duplicating expense #86093

Closed

Description

@jponikarchuk

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: 9.3.42-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #83896
Email or phone of affected tester (no customers): sdjsdjosijnsodiosd@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create an expense with negative amount.
  4. Open the expense.
  5. Click More > Duplicate expense.
  6. Open the duplicated expense.

Expected Result:

The duplicated expense will have negative amount.

Actual Result:

The duplicated expense shows positive amount.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    DeployBlockerCash
    Bug
    on Mar 23, 2026
  2. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #83896

  3. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 23, 2026

    @github-actions
    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.
  5. OSBotify commented on Mar 23, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #83896 - "Implement core "Duplicate report" action logic." by @Krishna2323 (High confidence)
    Related Issues: None found

    Recommendation: REVERT

    The PR introduced a bug in the duplicate report functionality where negative expense amounts are converted to positive amounts. This is a clear regression that breaks expected behavior for duplicating negative expenses.

    Labels: No label changes made (keeping DeployBlockerCash as this is a frontend bug in the App repository)

    📋 Detailed Analysis

    Evidence

    Verification

    • The affected code is in /home/runner/_work/App/App/src/libs/actions/IOU/Duplicate.ts
    • Line 524 contains: amount: Math.abs(transactionDetails?.amount ?? 0),
    • Line 525 contains: taxAmount: Math.abs(transactionDetails?.taxAmount ?? 0),
    • This code is in the buildDuplicateTransactionParams function which is called by both duplicateExpenseTransaction and duplicateReport functions
    • PR Implement core "Duplicate report" action logic. #83896 modified this file extensively (299 additions, 87 deletions)

    Root Cause

    The buildDuplicateTransactionParams function applies Math.abs() to the amount when duplicating transactions. This was likely done to ensure amounts are positive, but it incorrectly converts negative amounts (which are valid in Expensify for refunds, corrections, etc.) to positive values.

    The bug occurs at line 524 in src/libs/actions/IOU/Duplicate.ts:

    amount: Math.abs(transactionDetails?.amount ?? 0),

    When a negative expense is duplicated, Math.abs() strips the negative sign, resulting in a positive amount in the duplicated expense.

    Fix Required

    Remove the Math.abs() call from the amount field (and potentially taxAmount) to preserve the original sign of the amount when duplicating.

  6. MelvinBot commented on Mar 23, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When duplicating an expense that has a negative amount (e.g., a credit or refund), the duplicated expense shows a positive amount instead of preserving the negative sign.

    What is the root cause of that problem?

    The root cause is Math.abs() applied to both amount and taxAmount in buildDuplicateTransactionParams() at src/libs/actions/IOU/Duplicate.ts:524-525:

    amount: Math.abs(transactionDetails?.amount ?? 0),
    taxAmount: Math.abs(transactionDetails?.taxAmount ?? 0),
    

    This was introduced in PR #83896. Here's how the sign is lost:

    1. A negative expense on an expense report is stored with a positive amount in Onyx (expense reports negate amounts for storage).
    2. getTransactionDetails(transaction) calls getAmount(), which negates the stored value back to a negative display amount (e.g., stored +5000 becomes -5000).
    3. Math.abs() strips the negative sign, forcing it to 5000.
    4. getMoneyRequestInformation() then negates again for expense report storage (-5000), which represents a normal positive expense — the credit/refund semantics are lost.

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

    Remove Math.abs() from lines 524-525 of src/libs/actions/IOU/Duplicate.ts, passing the amount directly:

    • amount: transactionDetails?.amount ?? 0
    • taxAmount: transactionDetails?.taxAmount ?? 0

    This is safe because getTransactionDetails() already returns correctly sign-corrected amounts. For non-expense-report transactions, getAmount() already applies Math.abs() internally (since "IOU requests cannot have negative values"). For expense report transactions, the sign is meaningful and should be preserved.

    What alternative solutions did you explore? (Optional)

    An alternative would be to call getTransactionDetails(transaction, undefined, undefined, true) with allowNegativeAmount=true and keep Math.abs(). However, this is more complex and still doesn't solve the problem — allowNegativeAmount only affects the non-expense-report code path, and the expense report path already returns the correct signed amount regardless of that flag. Simply removing Math.abs() is the minimal and correct fix.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. Krishna2323 commented on Mar 23, 2026

    @Krishna2323
    Contributor

    Working on the PR...

  8. Krishna2323 commented on Mar 23, 2026

    @Krishna2323
    Contributor

    PR ready for review: #86098

    cc: @hungvu193

  9. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    ⚠️ 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.

  10. added
    Reviewing
    on Mar 23, 2026
  11. 6 remaining items

  12. added
    Weekly
    Awaiting Payment
    and removed
    Hourly
    on Mar 24, 2026
  13. changed the title [-][RCA #83896] Expense - Negative amount is changed to positive amount after duplicating expense[/-] [+][Due for payment 2026-03-31] [RCA #83896] Expense - Negative amount is changed to positive amount after duplicating expense[/+] on Mar 24, 2026
  14. removed
    Reviewing
    on Mar 24, 2026
  15. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.42-3 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 2026-03-31. 🎊

  17. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    @Valforte 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]

  18. melvin-bot commented on Mar 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  19. added
    Weekly
    and removed
    Weekly
    on Mar 25, 2026
  20. changed the title [-][Due for payment 2026-03-31] [RCA #83896] Expense - Negative amount is changed to positive amount after duplicating expense[/-] [+][Due for payment 2026-04-01] [Due for payment 2026-03-31] [RCA #83896] Expense - Negative amount is changed to positive amount after duplicating expense[/+] on Mar 25, 2026
  21. melvin-bot commented on Mar 25, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.43-3 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 2026-04-01. 🎊

  22. melvin-bot commented on Mar 25, 2026

    @melvin-bot

    @Valforte @mallenexpensify 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]

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

Metadata

Metadata

Labels

Awaiting PaymentBugEngineeringWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions