Skip to content

Expense - App redirects to add receipt page after refreshing confirm page with receipt #90025

Closed

Description

@lanitochka17

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.69-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: #89313
Email or phone of affected tester (no customers): sjdosjdosjdojnsodj@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. Click + > Create expense > Manual.
  4. Enter amount > Next.
  5. On confirm page, add a receipt.
  6. Refresh confirm page.

Expected Result:

App will redirect to create expense flow after refreshing confirm page with receipt.

Actual Result:

App redirects to add receipt page after refreshing confirm page with receipt.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7148498_1778255602203.10.mp4

View all open jobs on GitHub

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on May 8, 2026

    @melvin-bot

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

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

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #89313 - "Guard against empty receipt source in ReceiptFileValidator" by @MelvinBot (High confidence)
    Related Issues: #88975 (the issue PR #89313 was attempting to fix)

    Recommendation: REVERT

    PR #89313 changed the timing of setMoneyRequestReceipt in ReceiptFileValidator.tsx, which unblocked a navigation path that was previously suppressed by effect cleanup, causing the redirect to the SCAN step instead of the create expense flow on page refresh.

    Assigned: @MelvinBot (PR author), @FitseTLT (approving reviewer), @Julesssss (approving reviewer)
    Labels: DeployBlockerCash kept (frontend App PR caused the regression). No label changes made.

    Detailed Analysis

    Evidence

    Verification

    • Affected file: src/pages/iou/request/step/confirmation/ReceiptFileValidator.tsx
    • PR Guard against empty receipt source in ReceiptFileValidator #89313 exclusively modifies this file (confirmed via gh pr view 89313 --json files).
    • The pre-PR version of the file was retrieved from staging commit history and compared against the current version.

    Root Cause

    Before PR #89313, setMoneyRequestReceipt was called synchronously inside the onFailure callback (during the Promise.all map). This caused an immediate Onyx state update that triggered a React re-render, which ran the useEffect cleanup and set ignore = true. By the time .then() ran, ignore was already true, so the Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_SCAN...) call was skipped.

    PR #89313 deferred setMoneyRequestReceipt to after Promise.all resolves (using the resetInitialTransactionReceipt flag), specifically to prevent the effect from retriggering mid-promise. However, this side effect of the old timing — suppressing the SCAN navigation via ignore = true — was a behavioral dependency that the fix inadvertently removed.

    After PR #89313, when a MANUAL expense is created, a receipt is added on the confirm page, and the user refreshes, the onFailure callback fires (blob URL is invalid), isScanFilesCanBeRead is set to false, and the .then() block runs with ignore = false. The code hits if (requestType === CONST.IOU.REQUEST_TYPE.MANUAL) (line 109) and navigates to ROUTES.MONEY_REQUEST_STEP_SCAN — the "add receipt page" — instead of the create expense flow.

    The navigation to MONEY_REQUEST_STEP_SCAN for MANUAL was pre-existing and appears intentional for the SCAN-initiated flow (issue #88975). However, it is incorrect for a MANUAL expense where the receipt was added on the confirm page — the user should be redirected to the manual entry step, not the receipt scan step.

  6. MelvinBot commented on May 8, 2026

    @MelvinBot
    Contributor

    Proposal

    Problem

    PR #89313 fixed a bug where a stale receipt left the "Create Expense" button enabled (#88975), but introduced a regression: refreshing the confirmation page now always redirects SCAN-type expenses to the "add receipt" page and deletes draft transactions.

    Solution

    The root cause is in ReceiptFileValidator.tsx:98-116. PR #89313 moved setMoneyRequestReceipt from the onFailure callback (line 87) into the .then() block (line 99-101), before the ignore check (line 102). Previously, calling setMoneyRequestReceipt inside onFailure triggered an Onyx update → re-render → effect cleanup set ignore = true → .then() exited early → no redirect. Now, ignore is still false when .then() runs, so the redirect always fires.

    The mechanism: blob:// receipt URLs don't survive page refresh. After refresh, validateReceiptFile fails → isScanFilesCanBeRead = false → draft transactions are deleted (line 113) → user is redirected to the scan page (line 115).

    The fix should make the validator distinguish between "receipt was never attached" and "receipt was lost due to refresh." When a receipt source exists in Onyx but the blob URL is unreadable, the validator should clear the receipt source (as it does now) but stay on the confirmation page and prompt the user to re-attach the receipt, rather than nuking the entire draft and redirecting.

    Concretely, after resetInitialTransactionReceipt clears the receipt in the .then() block, the code should return early instead of falling through to the redirect/delete logic — the user's other expense data (amount, merchant, category) is still valid and shouldn't be lost.

    Investigation details

    Data flow on refresh:

    1. User creates expense with scanned receipt (blob:// URL stored in Onyx)
    2. Page refresh — browser clears blob store, Onyx restores draft with stale blob:// URL
    3. ReceiptFileValidator effect runs: isLocalFile('blob://...') → true
    4. validateReceiptFile tries to fetch blob → fails
    5. onFailure: sets resetInitialTransactionReceipt = true, isScanFilesCanBeRead = false
    6. .then(): calls setMoneyRequestReceipt(id, '', '', true, '') — clears receipt
    7. ignore is still false → proceeds to delete drafts and redirect to scan page

    Key files:

    Related issue: #88975 — the original bug this PR was fixing (receipt disappears but Create button stays enabled).


    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. FitseTLT commented on May 8, 2026

    @FitseTLT
    Contributor

    @lanitochka17 my bad this is expected behavior. I gave u only the receipt expense step on the PR. If it is a manual expense with receipt it should indeed redirect to add receipt page because we don't need to reset the flow as it is manual. We can close it @Julesssss BTW this is an already existing feature we only fixed it to work on that pr. We did not change any behavior.

  8. Julesssss commented on May 8, 2026

    @Julesssss
    Contributor

    Thanks @FitseTLT. Yeah I agree. Closing

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