Skip to content

[Due for payment 2026-05-18] [$250] Receipt Disappears on Confirm Page After Refresh While “Create Expense” Remains Enabled #88975

Closed

Description

@m-natarajan

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.62-6
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @FitseTLT
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Navigate to workspace chat or Click global +
  2. Choose Scan
  3. Upload a receipt to create an expense
  4. Refresh the page
  5. Observe the receipt preview and button state

Expected Result:

Receipt should:
Remain visible after refresh, OR
If receipt data is lost:
The Create Expense flow starts

Actual Result:

Receipt preview disappears
Create Expense button remains enabled
User can proceed without confirming receipt

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

2026-04-27.19-11-23.mp4
Recording.2760.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022052386929549938273
  • Upwork Job ID: 2052386929549938273
  • Last Price Increase: 2026-05-07
  • Automatic offers:
    • FitseTLT | Reviewer | 111353456

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Apr 27, 2026

    @melvin-bot

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

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

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    There's a race condition in ReceiptFileValidator.tsx.

    On web, receipt images are stored as blob:// URLs via URL.createObjectURL(). The URL string is persisted in the Onyx TRANSACTION_DRAFT, but the actual blob data lives only in browser memory and is lost on page refresh.

    ReceiptFileValidator is supposed to detect expired blob URLs and redirect the user back to the scan step. Here's why it fails:

    1. On refresh, the effect tries to fetch() the stale blob:// URL — this fails as expected.
    2. The onFailure callback calls setMoneyRequestReceipt(transactionID, '', '', true, ''), which updates Onyx and triggers a re-render.
    3. The re-render runs the effect's cleanup function, setting ignore = true.
    4. When Promise.all(...).then() finally executes, it checks ignore and bails — the navigation to restart the scan flow never happens.
    5. The effect re-runs. Now receipt.source = ''. isLocalFile('') returns false because empty string is falsy, so the validator treats it as a valid non-local (remote) file and adds it to receiptFiles.
    6. receiptFiles becomes non-empty → loading indicator hides, button enables. But the receipt source is empty → nothing renders.

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

    In ReceiptFileValidator.tsx, the non-local file branch (line 64) should also verify the receipt source is truthy before treating it as valid. An empty-source receipt should not be added to receiptFiles:

    if (!isLocalFile) {
        if (item.receipt && itemReceiptPath) {  // add itemReceiptPath check
            newReceiptFiles = {...newReceiptFiles, [item.transactionID]: item.receipt};
        }
        return Promise.resolve();
    }
    

    This prevents the second effect run (after onFailure clears the source to '') from populating receiptFiles with an invalid receipt, so the loading state persists and the button stays disabled. Meanwhile, a subsequent effect re-run with requestType defined will correctly hit the navigation path since isScanFilesCanBeRead will be false (no local files succeed) and the ignore flag won't be set.

    What alternative solutions did you explore? (Optional)

    An alternative would be to avoid calling setMoneyRequestReceipt inside the Promise callback (which triggers the re-render/ignore race). Instead, the cleanup and navigation could be deferred to the .then() handler. However, the simpler itemReceiptPath guard is a more targeted fix that also protects against other scenarios where a receipt might have an empty source.


    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. FitseTLT commented on Apr 27, 2026

    @FitseTLT
    Contributor

    @MelvinBot what's the offending pr as it is a deploy blocker

  7. OSBotify commented on Apr 27, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #86023 - "[Odometer] Blob URL loss detection" by @jakubkalinski0 (Medium confidence)
    Related Issues: None found

    Recommendation: NEEDS INVESTIGATION

    While PR #86023 is the most direct candidate — it modified ReceiptFileValidator.tsx and the receipt validation flow that runs on page refresh — I could not definitively confirm it introduced the regression without being able to run the code. The author and reviewers should verify the failure scenario.

    Assigned: @jakubkalinski0 (PR author), @DylanDylann, @Julesssss (approving reviewers) from highest-confidence causing PR only
    Labels: No label changes made. DeployBlockerCash is appropriate because the fix requires an App change.

    Detailed Analysis

    Evidence

    The bug: After uploading a receipt via the Scan flow and refreshing the page on the confirmation screen, the receipt preview disappears but the "Create Expense" button remains enabled. The expected behavior is either that the receipt remains visible OR the flow restarts from the beginning.

    The mechanism: When a browser page refreshes, blob:// URLs stored in the transaction draft (persisted in Onyx via localStorage) become invalid — the binary data in browser memory is gone. The ReceiptFileValidator component is responsible for detecting this and navigating the user back to the start of the scan flow.

    Why PR 86023 is the candidate: It directly modifies ReceiptFileValidator.tsx (src/pages/iou/request/step/confirmation/ReceiptFileValidator.tsx) to add the backToReport parameter and pass action and backToReport to navigateToStartMoneyRequestStep. Before this PR, those arguments were omitted.

    Possible failure path: A race condition exists in ReceiptFileValidator's useEffect:

    1. On refresh, ReceiptFileValidator runs: detects the blob URL is expired, calls onFailure.
    2. onFailure calls setMoneyRequestReceipt(id, '', '', true, '') which immediately triggers an async Onyx merge on the transaction draft.
    3. The Onyx update changes the transactions prop (which is a dependency of the useEffect), triggering a cleanup — setting ignore = true.
    4. The Promise.all().then() callback runs and finds ignore === true, so it returns early — navigation is skipped.
    5. The receipt is now cleared (blank preview) but the user is left on the confirmation page with the Create Expense button still active.

    This race condition would have existed before PR 86023 too, but the addition of backToReport could have changed the async timing. Additionally, if ReceiptFileValidator.tsx was first introduced or substantially changed in this staging cycle (as suggested by the confirmation/ directory decomposition pattern), the bug may be entirely new to this release.

    Why staging-only: The ReceiptFileValidator changes in PR 86023 are new in the staging cycle (merged 2026-04-23). Production (9.3.61-x) would not have these changes.

    Verification

    • Affected files: src/pages/iou/request/step/confirmation/ReceiptFileValidator.tsx
    • PR 86023 modifies this file: Confirmed — it adds backToReport prop and passes action, backToReport to navigateToStartMoneyRequestStep.
    • PR is in staging deploy: Confirmed — appears in StagingDeployCash Deploy Checklist: New Expensify 2026-04-23 #88633 as PR [Odometer] Blob URL loss detection #86023.
    • Bug only on web platforms: Confirmed — blob:// URL expiry only affects web (Chrome, Safari) where page refresh destroys in-memory blobs. Mobile native apps and native platforms are not affected, matching the platforms checked in the issue.

    Root Cause

    The ReceiptFileValidator component's useEffect has transactions as a dependency. When onFailure is called, it triggers setMoneyRequestReceipt which writes to ONYXKEYS.COLLECTION.TRANSACTION_DRAFT. This Onyx write causes a re-render, which re-evaluates the transactions dependency, which triggers the useEffect cleanup (setting ignore = true). The cleanup runs before the Promise.all().then() callback completes, so ignore === true when the callback runs, and the navigation back to the scan step is silently skipped. The user is left on the confirmation page with no receipt displayed but the Create Expense button still enabled.

    The fix should either:

    1. Move the navigation call out of the Promise.all().then() to prevent the ignore flag from blocking it, or
    2. Avoid calling setMoneyRequestReceipt inside onFailure before the navigation (or call it after navigation), or
    3. Use a separate useRef to track whether navigation has been triggered to prevent re-running on the re-render caused by the Onyx update.
  8. 37 remaining items

  9. melvin-bot commented on May 11, 2026

    @melvin-bot

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

  10. FitseTLT commented on May 12, 2026

    @FitseTLT
    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:

    • [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:

    • [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.

    • [] [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Test:

    1. Navigate to workspace chat or Click global +
    2. Choose Scan
    3. Upload a receipt to create an expense
    4. Refresh the page
    5. Verify the user is redirected to Create Expense flow

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-5ffe-a6b2-0028-7c0c6af0c194
  11. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 12, 2026
  12. melvin-bot commented on May 17, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  13. mallenexpensify commented on May 19, 2026

    @mallenexpensify
    Contributor

    Deploy Blocker ##90025 was identified to be related to this PR.

    From PR, I'm assuming this should be reduced cuz it wasn't addressed here. Is that correct @FitseTLT ?

  14. FitseTLT commented on May 19, 2026

    @FitseTLT
    Contributor

    No it is a false alarm. @mallenexpensify

  15. mallenexpensify commented on May 19, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @FitseTLT paid $250 via Upwork

    Thanks @FitseTLT please address on the issue due payment so I don't have to go dig around, it helps me pay folks promptly.

    ^ Test case created. Thx

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.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions