Skip to content

Offline - Report preview shows $0 total after moving multi-currency expenses to a newly crea #93919

Closed

Description

@applause-bot

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.4.10-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: #89564
Email or phone of affected tester (no customers): jsat@applausemail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Macbook Pro/iOS 13.7.8, iPhone 13/18.6.2, Samsung S21/Android 15
App Component: Other

Action Performed:

  1. Launch Expensify App
  2. Log in with valid credentials
  3. Go to a workspace chat
  4. Create 2 expenses with different currencies
  5. Click Submit
  6. Go to Spend > Reports
  7. Go offline
  8. Select the expense report via the checkbox
  9. Click Move expenses > Create report
  10. Observe the newly created report in the reports list

Expected Result:

The newly created report should display the correct total amount of the moved expenses in the report preview, even while offline

Actual Result:

The newly created report appears in a pending/greyed-out state and correctly shows that it contains 2 expenses, but its amount is displayed as $0 instead of the total amount of the moved expenses

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7184189_1781748197381.WEB-Repro.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Nathan Lemma
Bug ID: 7184189

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 18, 2026
  2. melvin-bot commented on Jun 18, 2026

    @melvin-bot

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

  3. melvin-bot commented on Jun 18, 2026

    @melvin-bot

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

  4. github-actions commented on Jun 18, 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. MelvinBot commented on Jun 18, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ Regression analysis for this deploy blocker. Suspected source: #89564 ("Fix stale expense report totals after offline mixed-currency moves"), which reworked the total logic in changeTransactionsReport.

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

    Offline, moving multiple expenses with different currencies into a newly created report (Move expenses → Create report) shows the report with the correct transaction count ("2 expenses") but a $0 total instead of the summed total.

    What is the root cause of that problem?

    In the target-report branch of changeTransactionsReport, the second (different-currency) expense trips the mixed-currency guard and calls markReportTotalAsStale(targetReportID):

    src/libs/actions/Transaction.ts:1376-1377

    markReportTotalAsStale → clearAccumulatedReportTotals deletes updatedReportTotals[targetReportID] and only sets pendingFields.total = UPDATE so the server recomputes later.

    For an existing report that's harmless — it keeps showing its last real server total until the backend recomputes. But a newly created report starts at total: 0 (ReportUtils.ts buildOptimisticExpenseReport), and the final totals loop only emits entries still present in updatedReportTotals:

    src/libs/actions/Transaction.ts:1637

    Since that entry was deleted, no optimistic total is ever written, and offline the server never recomputes → the new report stays at $0.

    Data flow & evidence
    1. Offline "Create report" builds the new report empty: total: 0.
    2. changeTransactionsReport loops the 2 moved transactions.
    3. Expense Some initial fixes and code style updates #1 (currency A): getTargetReportCurrencies returns an empty set → guard size > 1 is false → a total branch runs and currency A is added to the set (line 1403).
    4. Expense Fix spaces #2 (currency B ≠ A): set is now {A} → new Set([A, B]).size === 2 > 1 → markReportTotalAsStale(targetReportID).
    5. clearAccumulatedReportTotals deletes updatedReportTotals[newReportID]; only pendingFields.total = UPDATE is set.
    6. The totals loop at line 1637 finds no entry for the new report → no total pushed to optimisticData.
    7. Report keeps total: 0; transactionCount is pushed separately so the UI shows "2 expenses" + $0. Offline → server never recomputes → persists until reconnect.

    This explains why it's reproducible in staging (post-#89564) but not production, and why it manifests specifically on newly created targets (base total 0) rather than existing reports (which retain a prior real total).

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

    For an optimistic/newly-created target report (no server-side recompute coming while offline), the mixed-currency path should still write a numeric total instead of only flagging it stale. Two viable directions:

    • Accumulate a best-effort total using each transaction's convertedAmount (the same value already used in the convertedAmount branch) so the new report shows a real total in its own currency, or
    • Skip markReportTotalAsStale when the target is the freshly-built newReport and instead keep accumulating, so the totals loop emits a value.

    The stale path remains correct for existing reports — only the newly-created-report case needs a numeric total written.

    What alternative solutions did you explore?

    Reverting #89564 clears this blocker but reintroduces the stale-total bug that PR fixed, so a targeted fix is preferred over a revert.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/93919) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  6. nabi-ebrahimi commented on Jun 18, 2026

    @nabi-ebrahimi

    I think this is expected behavior for the mixed-currency move-all case while offline.

    As discussed in this comment, when the calculation requires online data such as currency conversion, the report row should remain pending/greyed-out until backend confirmation.

    So showing 0 on the newly created destination report together with the greyed-out state looks consistent with that expectation.

    cc @iwiznia @sobitneupane

  7. iwiznia commented on Jun 18, 2026

    @iwiznia
    Contributor

    @nabi-ebrahimi you are right about the total, but why is the new report not showing the transactions in the list?
    Image

  8. nabi-ebrahimi commented on Jun 18, 2026

    @nabi-ebrahimi

    @nabi-ebrahimi you are right about the total, but why is the new report not showing the transactions in the list?

    @iwiznia I think this is out of scope of this PR and looks more like a navigation issue.

    The expenses are moved to the new report, but we stay on the old report instead of navigating to the newly created one.

    Screen.Recording.2026-06-18.at.4.58.27.PM.mov
  9. iwiznia commented on Jun 18, 2026

    @iwiznia
    Contributor

    Oh got it, closing then

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions