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
Spend - After adding several existing expenses offline, previous report shows incorrect amount #89354
Version Number: 9.3.65-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#85225 Email or phone of affected tester (no customers):ibellicotest+2250@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Search
Action Performed:
Prerequisite: Account has at least one workspace.
Open the staging.new.expensify.com website.
Open any workspace chat.
Create three manual expenses on the same report.
Create an empty report.
Navigate to "Spend" > "Reports"
Turn off internet connection.
Open the report created on step 4.
Click on "Add Expense" > "Add existing expense"
Select all the expenses from the remaining report and add them.
Return to "Reports"
Note that previous report, that is now empty, doesn´t show "0.00" as amount.
Turn on internet connection.
Note that now amount is correctly updated.
Expected Result:
After adding all the expenses from a report to another one while offline, first report should automatically display "0.00" as amount.
Actual Result:
After adding several existing expenses to a report while in offline mode, amount on previous report is not correctly updated.
👋 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:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #85225 - "Feat: Change Add unreported expense to Add existing expense in a report" by @nyomanjyotisa (High confidence) Related Issues: #84130
Recommendation: REVERT
PR #85225 expanded the "Add existing expense" flow to also surface expenses from open Draft reports (not just purely unreported/selfDM expenses). This exposed a bug in the changeTransactionsReport optimistic total calculation logic in src/libs/actions/Transaction.ts: when multiple expenses are moved from the same source Draft report, only the first transaction's amount is deducted from the source report's optimistic total, and subsequent deductions are silently dropped. The result is that the source report's displayed amount does not update to "0.00" after all expenses are moved away while offline. Before this PR, the flow only handled truly unreported transactions (no backing oldReport in Onyx), so the stale-total code path was never triggered for a real source report.
Assigned: @nyomanjyotisa (PR author), @puneetlath and @sobitneupane (approving reviewers) from highest-confidence causing PR only Labels: DeployBlockerCash kept (frontend App PR is the cause). No label changes made.
Affected file: src/libs/actions/Transaction.ts (the changeTransactionsReport function, specifically the updatedReportTotals accumulation loop around lines 1206-1226).
PR Feat: Change Add unreported expense to Add existing expense in a report #85225 does not directly modify Transaction.ts, but it changed src/pages/AddExistingExpense.tsx and src/selectors/Report.ts to allow Draft-report expenses to be selected, which routes them through the changeTransactionsReport code path with a real source report ID.
Root Cause
In changeTransactionsReport (Transaction.ts), the logic that accumulates the optimistic total for the source (old) report contains a bug at line 1216:
updatedReportTotal at line 1207 is computed as oldReport.total ± transactionAmount, where oldReport.total is always the original report total from Onyx, not the running accumulated total. After the first transaction is processed for a given source report, updatedReportTotals[oldReportID] is set, so the ternary never updates it again for subsequent transactions from the same report. Only the first transaction's deduction is applied; all remaining deductions are lost.
Before PR #85225, this code path was unreachable for a real source report because the "Add unreported expense" flow only picked up transactions with reportID === '' or CONST.REPORT.UNREPORTED_REPORT_ID. These transactions have no backing oldReport in Onyx, so the if (oldReport) block (line 1209) was skipped entirely and the total was simply marked stale. PR #85225 introduced openExpenseReportIDsSelector and used it in getEligibleTransactions to also surface expenses from open Draft reports, giving them a real oldReport. When a user selects all expenses from such a Draft report and adds them while offline, the accumulated total deduction is wrong and the source report does not display "0.00".
When multiple transactions are moved from one report to another via "Add existing expense", the source report's optimistic total only accounts for the first transaction removed. The bug is in changeTransactionsReport — line 1216:
This ternary sets the value on the first iteration, then preserves it for all subsequent transactions from the same source report. The second and third expense removals are silently dropped.
By contrast, the target report correctly accumulates at line 1239:
The same accumulation bug also affects updatedReportTotal itself — it's recalculated from the original oldReport.total each iteration (line 1206–1207), not from the running accumulated value, so even if the ternary guard were removed, only the last transaction's adjustment would be applied rather than the sum of all.
What changes do you think we should make in order to solve the problem?
Replace line 1216 with the same accumulation pattern used for the target report:
This reads the previously accumulated value (or falls back to the original report total), then adjusts it for each transaction removed — matching the pattern at lines 1239–1240 and the existing nonReimbursableTotal accumulation at lines 1217–1219.
What alternative solutions did you explore? (Optional)
None — the fix is a straightforward alignment with the existing correct pattern already used for the target report totals.
Investigation details
Concrete example: Report A has 3 expenses ($20, $20, $10) → total = -5000 cents.
Transaction moved
oldReportTotal (from report)
updatedReportTotal
updatedReportTotals[oldReportID] stored
1st ($20)
-5000
-3000
-3000 ✓
2nd ($20)
-5000 (re-read from report, not accumulated)
-3000
-3000 (truthy → kept) ✗ should be -1000
3rd ($10)
-5000
-4000
-3000 (truthy → kept) ✗ should be 0
Result: source report shows $30 instead of $0.00 until the server corrects it.
Transaction.ts:1217-1219 — nonReimbursableTotal on source report also correctly accumulates (inconsistency confirms the bug)
Transaction.ts:1496-1501 — optimistic data IS pushed for source report; the issue is the value is wrong
Possibly related:#75134 (expense preview shows wrong amount after moving offline) — may share the same root cause.
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.
Activity
melvin-bot commentedon May 1, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #85225
melvin-bot commentedon May 1, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon May 1, 2026
👋 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:
OSBotify commentedon May 1, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #85225 - "Feat: Change Add unreported expense to Add existing expense in a report" by @nyomanjyotisa (High confidence)
Related Issues: #84130
Recommendation: REVERT
PR #85225 expanded the "Add existing expense" flow to also surface expenses from open Draft reports (not just purely unreported/selfDM expenses). This exposed a bug in the
changeTransactionsReportoptimistic total calculation logic insrc/libs/actions/Transaction.ts: when multiple expenses are moved from the same source Draft report, only the first transaction's amount is deducted from the source report's optimistic total, and subsequent deductions are silently dropped. The result is that the source report's displayed amount does not update to "0.00" after all expenses are moved away while offline. Before this PR, the flow only handled truly unreported transactions (no backingoldReportin Onyx), so the stale-total code path was never triggered for a real source report.Assigned: @nyomanjyotisa (PR author), @puneetlath and @sobitneupane (approving reviewers) from highest-confidence causing PR only
Labels:
DeployBlockerCashkept (frontend App PR is the cause). No label changes made.Detailed Analysis
Evidence
StagingDeployCashchecklist for version9.3.65-0, confirming it is part of this staging release and was not in production.Verification
src/libs/actions/Transaction.ts(thechangeTransactionsReportfunction, specifically theupdatedReportTotalsaccumulation loop around lines 1206-1226).src/pages/AddExistingExpense.tsx(renamed and expanded fromAddUnreportedExpense.tsxby PR Feat: Change Add unreported expense to Add existing expense in a report #85225).Transaction.ts, but it changedsrc/pages/AddExistingExpense.tsxandsrc/selectors/Report.tsto allow Draft-report expenses to be selected, which routes them through thechangeTransactionsReportcode path with a real source report ID.Root Cause
In
changeTransactionsReport(Transaction.ts), the logic that accumulates the optimistic total for the source (old) report contains a bug at line 1216:updatedReportTotalat line 1207 is computed asoldReport.total ± transactionAmount, whereoldReport.totalis always the original report total from Onyx, not the running accumulated total. After the first transaction is processed for a given source report,updatedReportTotals[oldReportID]is set, so the ternary never updates it again for subsequent transactions from the same report. Only the first transaction's deduction is applied; all remaining deductions are lost.Before PR #85225, this code path was unreachable for a real source report because the "Add unreported expense" flow only picked up transactions with
reportID === ''orCONST.REPORT.UNREPORTED_REPORT_ID. These transactions have no backingoldReportin Onyx, so theif (oldReport)block (line 1209) was skipped entirely and the total was simply marked stale. PR #85225 introducedopenExpenseReportIDsSelectorand used it ingetEligibleTransactionsto also surface expenses from open Draft reports, giving them a realoldReport. When a user selects all expenses from such a Draft report and adds them while offline, the accumulated total deduction is wrong and the source report does not display "0.00".MelvinBot commentedon May 1, 2026
Proposal
What is the root cause of that problem?
When multiple transactions are moved from one report to another via "Add existing expense", the source report's optimistic
totalonly accounts for the first transaction removed. The bug is inchangeTransactionsReport— line 1216:This ternary sets the value on the first iteration, then preserves it for all subsequent transactions from the same source report. The second and third expense removals are silently dropped.
By contrast, the target report correctly accumulates at line 1239:
The same accumulation bug also affects
updatedReportTotalitself — it's recalculated from the originaloldReport.totaleach iteration (line 1206–1207), not from the running accumulated value, so even if the ternary guard were removed, only the last transaction's adjustment would be applied rather than the sum of all.What changes do you think we should make in order to solve the problem?
Replace line 1216 with the same accumulation pattern used for the target report:
This reads the previously accumulated value (or falls back to the original report total), then adjusts it for each transaction removed — matching the pattern at lines 1239–1240 and the existing
nonReimbursableTotalaccumulation at lines 1217–1219.What alternative solutions did you explore? (Optional)
None — the fix is a straightforward alignment with the existing correct pattern already used for the target report totals.
Investigation details
Concrete example: Report A has 3 expenses ($20, $20, $10) → total = -5000 cents.
oldReportTotal(from report)updatedReportTotalupdatedReportTotals[oldReportID]storedResult: source report shows $30 instead of $0.00 until the server corrects it.
Evidence chain:
Transaction.ts:1216— source report total set-once bugTransaction.ts:1239-1240— target report correctly accumulatesTransaction.ts:1217-1219—nonReimbursableTotalon source report also correctly accumulates (inconsistency confirms the bug)Transaction.ts:1496-1501— optimistic data IS pushed for source report; the issue is the value is wrongPossibly related: #75134 (expense preview shows wrong amount after moving offline) — may share the same root cause.
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.nyomanjyotisa commentedon May 1, 2026
I don't think this issue is caused by
#85225, since the same issue occurs in production, just with a different reproduction stepsMacOS-Chrome.mp4
sobitneupane commentedon May 1, 2026
It's not a regression. We have been working on this in another issue for quite some time.
puneetlath commentedon May 1, 2026
Closing in favor of that issue.