Skip to content

Scan - User directed to create expense page after capturing multiple receipt via scan icon #84377

Closed

Description

@jponikarchuk

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: V9.3.32-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-7763/folder/13176932/41237693/1232119333
Email or phone of affected tester (no customers): dreamnitethedragon+yydyd373@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Redminote 10S Android 13
App Component: User Settings

Action Performed:

  1. Launch app
  2. Tap scan icon ( green camera icon)
  3. Tap multiple scan receipt icon
  4. Capture few images and tap side arrow
    5.select a user

Expected Result:

User must be able to create expense after capturing multiple receipt via scan icon.

Actual Result:

User directed to create expense page after capturing multiple receipt via scan icon.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Bug
    on Mar 6, 2026
  2. melvin-bot commented on Mar 6, 2026

    @melvin-bot

    Triggered auto assignment to @trjExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. melvin-bot commented on Mar 6, 2026

    @melvin-bot

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

  4. melvin-bot commented on Mar 6, 2026

    @melvin-bot

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

  5. github-actions commented on Mar 6, 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.
  6. OSBotify commented on Mar 6, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #83470 - "Scan Receipt UX/perf improvements" by @marcaaron (High confidence)
    Related Issues: #83469 (the issue that PR #83470 was fixing)

    Recommendation: REVERT

    PR #83470 introduced significant changes to the receipt scanning camera flow, including freezing the camera on capture and refactoring the capture state management. The changes are extensive and affect critical timing-sensitive code paths in the multi-scan receipt flow. A revert is the safest approach to unblock the deploy while the issue is investigated and fixed properly.

    Labels: Keeping DeployBlockerCash label (App deploy is blocked due to frontend bug)

    Detailed Analysis

    Evidence

    PR #83470 was merged on March 3, 2026 and modified the scan receipt camera implementation (src/pages/iou/request/step/IOURequestStepScan/index.native.tsx). The PR made several changes:

    1. Added camera freezing on capture (forceInactive={isAttachmentPickerActive || didCapturePhoto})
    2. Refactored capture state from didCapturePhoto to isCapturingPhoto.current ref for double-tap protection
    3. Removed image cropping from the native capture path
    4. Pre-created upload directory during initialization

    The issue affects the multi-scan receipt flow specifically on Android native, which is the primary platform modified by this PR.

    Verification

    Confirmed that PR #83470:

    • Modified src/pages/iou/request/step/IOURequestStepScan/index.native.tsx (85 additions, 83 deletions)
    • Merged to main on March 3, 2026 at 21:19:05 UTC
    • Is included in staging (commit 245e40a is on staging branch)
    • Affects the scan receipt camera behavior on Android native (the reported platform)

    Root Cause

    The PR changed how camera state is managed during photo capture. Specifically:

    • Line 375: setDidCapturePhoto(true) is called after photo capture
    • Line 505: Camera becomes inactive when didCapturePhoto is true via forceInactive prop
    • Lines 407-410: In multi-scan mode, state is reset with setDidCapturePhoto(false) and isCapturingPhoto.current = false

    There appears to be a timing issue or state synchronization problem in the multi-scan flow where the camera state changes and navigation logic may not work correctly after capturing multiple receipts. The refactoring from state to ref for capture protection and the addition of camera freezing likely introduced an edge case in the multi-scan user flow.

  7. MelvinBot commented on Mar 6, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When using the multi-scan receipt flow (tap scan icon → multi-scan → capture images → tap arrow → select participant), the user is redirected back to the "Create expense" page instead of proceeding to the confirmation page. This is reproducible on staging (V9.3.32-0) but not production.

    What is the root cause of that problem?

    Causing PR: #84317 ("[No QA] Sentry logs for Scan shortcut")

    This is the same root cause as deploy blocker #84363 (QAB returns to Create expense after entering amount). PR #84317 added iouRequestType to the transaction draft inside startMoneyRequest at src/libs/actions/IOU/index.ts:1378-1381:

    Onyx.set(`...TRANSACTION_DRAFT...`, {
        isFromFloatingActionButton,
        ...(requestType && {iouRequestType: requestType}),  // NEW in #84317
    });

    This triggers a chain reaction in the multi-scan flow:

    1. User taps the floating camera button, which calls startMoneyRequest(CREATE, reportID, SCAN, ..., isFromFloatingActionButton=true). The Onyx.set above pre-sets iouRequestType: 'scan' on the draft — but does not set transactionID.
    2. IOURequestStartPage renders and resetIOUTypeIfChanged at src/pages/iou/request/IOURequestStartPage.tsx:181 checks transaction?.iouRequestType === newIOUType. Both are 'scan', so it returns early and skips initMoneyRequest.
    3. initMoneyRequest is the only function that sets transactionID on the draft. Since it was skipped, the draft remains {isFromFloatingActionButton: true, iouRequestType: 'scan'} — missing transactionID, isFromGlobalCreate, reportID, etc.
    4. User captures multiple receipts, taps the arrow, and selects a participant. The app navigates to the confirmation page.
    5. The guard useEffect in IOURequestStepConfirmation at src/pages/iou/request/step/IOURequestStepConfirmation.tsx:402-415 checks transaction?.transactionID — finds it undefined — and calls startMoneyRequest(), which navigates the user back to the "Create expense" page.

    Before PR #84317, iouRequestType was never pre-set in startMoneyRequest, so resetIOUTypeIfChanged would always find a mismatch and call initMoneyRequest (which properly initializes transactionID and all other fields). This is why the bug only appears on staging.

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

    In startMoneyRequest at src/libs/actions/IOU/index.ts:1378, add transactionID: CONST.IOU.OPTIMISTIC_TRANSACTION_ID to the Onyx.set call so the draft is always initialized with a valid transactionID:

    Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, {
        isFromFloatingActionButton,
        transactionID: CONST.IOU.OPTIMISTIC_TRANSACTION_ID,  // add this
        ...(requestType && {iouRequestType: requestType}),
    });

    This ensures the confirmation page's guard useEffect sees a valid transactionID and does not redirect back, regardless of whether initMoneyRequest runs later.

    What alternative solutions did you explore? (Optional)

    1. Revert PR [No QA] Sentry logs for Scan shortcut #84317 entirely — This would fix both this issue and QAB-App returns to Create expense after enter amount and click Next if Create expense from QAB #84363 but would lose the scan shortcut telemetry that PR [No QA] Sentry logs for Scan shortcut #84317 was designed to add.
    2. Modify resetIOUTypeIfChanged to also check for transactionID existence — e.g., skip the early return if transactionID is missing. This is more defensive but changes the semantics of the function and could have broader side effects.

    The recommended fix (adding transactionID to Onyx.set) is the most targeted — it ensures the draft is properly initialized without changing any other behavior. This same fix resolves both this issue and #84363.


    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.

  8. added
    Reviewing
    on Mar 6, 2026
  9. rlinoz commented on Mar 6, 2026

    @rlinoz
    Contributor
  10. m-natarajan commented on Mar 6, 2026

    @m-natarajan

    Not Repro, Galaxy A55/ Android 16, v9.3.32-2

    repro.-.issue.84377.mp4
  11. removed
    DeployBlockerCash
    on Mar 6, 2026
  12. added a commit that references this issue on Mar 9, 2026
  13. IuliiaHerets commented on Mar 9, 2026

    @IuliiaHerets

    Xiaomi Redmi Note 10 / Android 12
    App 9.3.33-1 PR: 84552 Ad-Hoc
    Passed

    Screenrecorder-2026-03-09-18-29-30-429.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions