Skip to content

Report - Expense information is still visible on preview after being unreported. #87206

Closed

Description

@mitarachim

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.53-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: https://test-management.browserstack.com/projects/2219752/test-runs/TR-16381/folder/13176730/41237113/1309878798
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: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace.
Prerequisite 2: Account has Self DM.

  1. Open the staging.new.expensify.com website.
  2. Open any workspace chat.
  3. Create a manual expense.
  4. Open the just created expense.
  5. Click on the report field and select "Remove from report"
  6. Note that report is automatically displayed empty.
  7. Click on the arrow on the top left corner of report to return to chat.
  8. Note that expense information is still visible on preview.
  9. Navigate to another chat and return.
  10. Note that now, preview is displayed empty.

Expected Result:

After an expense is unreported, report preview should be displayed empty automatically.

Actual Result:

After an expense is unreported, report preview still displays expense information.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7123256_1775526620939.Unreport.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Apr 7, 2026
  2. melvin-bot commented on Apr 7, 2026

    @melvin-bot

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

  3. melvin-bot commented on Apr 7, 2026

    @melvin-bot

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

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

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The compute function in reportTransactionsAndViolations.ts:32 mutates currentValue in place instead of creating new object references when a transaction moves between reports.

    When "Remove from report" is triggered, changeTransactionsReport optimistically updates the transaction's reportID. This triggers the derived value to recompute, which correctly removes the transaction from the old report's group — but via in-place delete on the same object reference (line 41). The returned object has the same reference identity as before, so:

    1. useOnyx's shallowEqual check sees the same references and skips the re-render
    2. useMemo in useReportWithTransactionsAndViolations.ts:21 has [transactions, isOffline] as dependencies — the transactions reference didn't change, so it returns the cached (stale) filtered array
    3. MoneyRequestReportPreviewContent never sees transactions.length === 0, so it keeps showing the old expense data

    Navigating away and back forces a fresh mount that reads the (correctly mutated) current Onyx cache — which is why the workaround works.

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

    In the compute function of reportTransactionsAndViolations.ts, when a transaction is removed from a report (lines 40-46), create a new object for that report's entry instead of mutating the existing one. Specifically, when deleting a transaction from reportTransactionsAndViolations[previousReportID], replace the entry with a shallow copy:

    reportTransactionsAndViolations[previousReportID] = {
        transactions: { ...reportTransactionsAndViolations[previousReportID].transactions },
        violations: { ...reportTransactionsAndViolations[previousReportID].violations },
    };
    

    Then perform the delete on this new object. Similarly, when adding/updating a transaction for a report (line 79), create a new object for that report entry. This ensures downstream shallowEqual and useMemo dependency checks detect the change and trigger re-renders.

    What alternative solutions did you explore?

    An alternative would be to always deep-clone the entire currentValue at the start of compute, but that would be wasteful since we only need new references for the specific report entries that changed. The targeted approach of creating new sub-objects only for modified reports is more performant.


    Possibly related: #87179 ("Report Preview Not Updating After Adding Expense Until Manual Refresh") appears to have the same root cause — the in-place mutation pattern would affect any operation that moves transactions between reports.


    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.

  6. pecanoro commented on Apr 7, 2026

    @pecanoro
    Contributor

    This seems to be originating in the front end so removing the web deploy blocker label

  7. removed
    DeployBlockerIndicates it should block deploying the API
    on Apr 7, 2026
  8. roryabraham commented on Apr 7, 2026

    @roryabraham
    Contributor

    @MelvinBot what pull request on the deploy checklist would have caused this bug which is reproducible on staging but not production?

  9. MelvinBot commented on Apr 7, 2026

    @MelvinBot
    Contributor

    The most likely culprit is #86408 ("Revert 'Update customUnitRateID to _FAKE_P2P_ID_ when unreporting expense'").

    This is the only PR on the deploy checklist that directly modifies the "Remove from report" / unreporting code path. It changes changeTransactionsReport() in src/libs/actions/Transaction.ts to remove modifiedAmount, modifiedCurrency, and modifiedMerchant from the optimistic transaction update when unreporting. With fewer fields changing on the transaction object during the optimistic update, the derived value (REPORT_TRANSACTIONS_AND_VIOLATIONS) — which already mutates its data structures in-place — produces a weaker change signal, causing the report preview component to not re-render.

    A secondary suspect is #86924 (Onyx bump from 3.0.54 → 3.0.57), which could have changed how derived value updates are detected and propagated.

    Supporting evidence

    PR #86408 changes to the unreport flow (Transaction.ts:1041-1078):

    • Before: const {comment, modifiedAmount, modifiedCurrency, modifiedMerchant} = recalculateUnreportedTransactionDetails(...)
    • After: const {comment} = recalculateUnreportedTransactionDetails()
    • All callers of changeTransactionsReport also had translate/toLocaleDigit params removed

    Why the preview doesn't update:

    1. "Remove from report" calls changeTransactionsReport → optimistically changes transaction.reportID
    2. The derived value REPORT_TRANSACTIONS_AND_VIOLATIONS recomputes and removes the tx from the old report via in-place delete (mutation, not new object)
    3. Since the object reference doesn't change, useOnyx's shallow equality check skips the re-render
    4. Navigating away and back forces a fresh mount that reads the correct data — confirming this is a reactivity issue, not data corruption
  10. tylerkaraszewski commented on Apr 7, 2026

    @tylerkaraszewski
    Contributor
    Image

    I cannot duplicate this on my workspace. This is what I see as soon as removing the expense from the report.

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

Metadata

Metadata

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