Skip to content

[$250] Scan-Error modal is not displayed when Retry fails #83537

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: v9.3.26-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #77646
Email or phone of affected tester (no customers): agexptest+pr250226b@gmail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Samsung S23FE/ Android 16, iPhone 13 Mini/ iOS 26.1
App Component: Money Requests

Action Performed:

  1. Open the Expensify app
  2. Go to Troubleshoot > Enable Simulate failing network requests
  3. Create a scan expense
  4. Go to the expense details
  5. Wait until the error message appears
  6. Tap "Retry" link
  7. Wait for the confirm modal

Expected Result:

A confirm modal with a generic error message and "OK" button appears.

Actual Result:

The confirm modal does not appear. After dismissing the error message, the app redirects to the workspace room.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7088710_1772059569218.No_confirm_modal.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @getusha
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026910439458013314
  • Upwork Job ID: 2026910439458013314
  • Last Price Increase: 2026-02-26

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 26, 2026
  2. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (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. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 26, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  5. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

  6. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  7. changed the title [-]Scan-Error modal is not displayed when Retry fails[/-] [+][$250] Scan-Error modal is not displayed when Retry fails[/+] on Feb 26, 2026
  8. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a user creates a scan expense with "Simulate failing network requests" enabled and taps "Retry" after the error appears, the expected confirm modal (with a generic error message and "OK" button) does not appear. Additionally, after dismissing the error message, the app redirects to the workspace room instead of staying on the expense details page.

    What is the root cause of that problem?

    PR #77646 refactored DotIndicatorMessage.tsx to replace an inline <ConfirmModal> component (controlled by local useState) with the useConfirmModal hook from the global modal system. This introduced a behavioral change:

    The shouldHandleNavigationBack: true default: In src/hooks/useConfirmModal.ts:14, the hook always sets shouldHandleNavigationBack: true as a default prop when showing modals. The old inline ConfirmModal in DotIndicatorMessage did not have this prop set (defaulting to undefined/false).

    The retry flow works as follows:

    1. User taps "Retry" → handleRetryPress in ReceiptUploadRetryHandler attempts to reconstruct the receipt file from local storage
    2. On Android (index.android.ts), RNFS reads the local file; on iOS (index.ts), fetch(message.source) is called
    3. If file reconstruction fails, the error modal callback is triggered (this is the modal the issue is about)
    4. If file reconstruction succeeds, handleFileRetry calls dismissError() and re-dispatches the IOU action — no modal is shown

    When file reconstruction fails and the modal callback IS triggered, the new code calls showConfirmModal() which renders via the global ModalProvider at the app root level with shouldHandleNavigationBack: true. On web, this causes window.history.back() when the modal is dismissed, potentially navigating the user away. On native, this prop is not consumed by BaseModal directly but may affect the modal lifecycle through the ConfirmModalWrapper bridge component.

    The old inline ConfirmModal was rendered within DotIndicatorMessage's component tree and was always present in the DOM (just toggled via isVisible). The new approach mounts a fresh ConfirmModalWrapper into the ModalProvider only when triggered — this changes the rendering lifecycle and may interact differently with React Native's modal system on native platforms.

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

    In src/components/DotIndicatorMessage.tsx, pass shouldHandleNavigationBack: false in the showConfirmModal call to match the old inline ConfirmModal behavior:

    showConfirmModal({
        prompt: translate('common.genericErrorMessage'),
        confirmText: translate('common.ok'),
        shouldShowCancelButton: false,
        shouldHandleNavigationBack: false,
    });

    This restores the behavior where dismissing the error modal does NOT trigger a navigation back action.

    If this alone doesn't resolve the issue on native platforms, the DotIndicatorMessage should be reverted to use an inline ConfirmModal with local useState (as it was before PR #77646), until the global modal system's native rendering is verified to work correctly in all contexts.

    What alternative solutions did you explore? (Optional)

    1. Changing the default in useConfirmModal.ts to shouldHandleNavigationBack: false — this would affect all consumers of the hook and might break other modals that rely on the navigation back behavior.
    2. Investigating the ModalProvider rendering on native — the global modal system renders via ModalProvider at the app root. If there are issues with how ConfirmModalWrapper renders on native (timing, animation, z-index), those should be fixed in the modal system itself. However, the quickest fix is to match the old behavior for this specific modal.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  9. twilight2294 commented on Feb 26, 2026

    @twilight2294
    Contributor

    Proposal

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

    When a user creates a scan expense with "Simulate failing network requests" enabled and taps "Retry" after the initial error appears, the expected scan-error confirm modal does not display. Additionally, the app navigates away from the expense details page to the workspace room.

    What is the root cause of that problem?

    The root cause is in handleFileRetry() in handleFileRetry. When "Retry" is pressed, this function calls dismissError() before re-dispatching the IOU action. The dismissError callback originates from dismissReceiptError() in MoneyRequestReceiptView.

    When transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, dismissReceiptError() calls cleanUpMoneyRequest(), which deletes the entire transaction, report action, and associated report — then navigates the user away. This is correct behavior when the user wants to permanently dismiss an error, but it is destructive when called as part of a retry flow.

    After dismissError() destroys the transaction context, requestMoney() (or trackExpense()) is called to create a brand new expense. Because "Simulate failing network requests" is enabled, this new request also fails. However, the user has already been navigated away from the original expense details page (since the underlying report was deleted by cleanUpMoneyRequest()), so they never see the new error or the scan-error modal. The modal callback passed as setShouldShowErrorModal in DotIndicatorMessage is never triggered because the retry's file-fetch succeeds — the failure happens later at the network level, after the component has already unmounted due to the navigation caused by cleanup.

    This is fundamentally different from the existing proposal's root cause, which focuses on shouldHandleNavigationBack in the useConfirmModal hook. The real problem is that the retry flow never gets to the point of showing any modal at all — the transaction and its containing report are deleted before the retry request can fail and surface an error.

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

    In handleFileRetry, instead of calling the full dismissError() (which triggers cleanUpMoneyRequest and navigates away), we should only clear the transaction errors. We can use Transaction.clearError() to remove the error from the transaction without destroying the entire money request context:

    // In handleFileRetry.ts
    import * as Transaction from '@libs/actions/Transaction';
    
    function handleFileRetry(
        retryParams: ReceiptError['retryParams'],
        file: FileObject,
        transactionID: string,
        setShouldShowErrorModal: () => void,
    ) {
        switch (retryParams.actionType) {
            case CONST.IOU.ACTION_PARAMS.MONEY_REQUEST: {
                Transaction.clearError(transactionID);
                const requestMoneyParams = {...retryParams} as IOU.RequestMoneyInformation;
                requestMoneyParams.transactionParams.receipt = file;
                requestMoneyParams.isRetry = true;
                requestMoneyParams.shouldPlaySound = false;
                IOU.requestMoney(requestMoneyParams);
                break;
            }
            case CONST.IOU.ACTION_PARAMS.TRACK_EXPENSE: {
                Transaction.clearError(transactionID);
                const trackExpenseParams = {...retryParams} as IOU.TrackExpenseInformation;
                trackExpenseParams.transactionParams.receipt = file;
                trackExpenseParams.isRetry = true;
                trackExpenseParams.shouldPlaySound = false;
                IOU.trackExpense(trackExpenseParams);
                break;
            }
            // ... other cases similarly updated
        }
    }
    

    The transactionID can be obtained from the retryParams (already available as retryParams.transactionParams.transactionID) and threaded through from DotIndicatorMessage where receiptError already contains the transaction details. This way, the error is cleared so the UI updates, but the transaction and report remain intact for the retry to operate on. If the retry fails again, the error will be re-set on the same transaction and the user will remain on the same page to see it.

    What alternative solutions did you explore? (Optional)

    1. Adding a isRetry flag to dismissReceiptError — This would skip the cleanUpMoneyRequest path when called from a retry context. However, this leaks retry-awareness into a function that shouldn't need to know about it, and the cleaner approach is to simply not call the full dismiss flow during retries.

    2. Calling Onyx.merge directly to clear just the transaction errors — This would work but using the existing Transaction.clearError() action is more consistent with the codebase patterns.

  10. marufsharifi commented on Feb 26, 2026

    @marufsharifi

    Proposal

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

    When a user retries a failed scan expense, the app should stay on the same expense and show the correct retry-failure UX.

    Instead, before the fix:

    • retry could navigate the user away by triggering destructive cleanup
    • even if that cleanup was avoided, the original error could disappear and the retry failure was not surfaced on the current expense
    • the expected scan-error modal was not shown reliably

    What is the root cause of that problem?

    This is primarily a retry-flow bug, not just a modal bug.

    The first issue is in handleFileRetry(), which called dismissError() before re-dispatching retry actions (requestMoney, trackExpense, etc.):

    case CONST.IOU.ACTION_PARAMS.REPLACE_RECEIPT: {
    dismissError();
    const replaceReceiptParams = {...retryParams} as IOU.ReplaceReceipt;
    replaceReceiptParams.file = file;
    IOU.replaceReceipt(replaceReceiptParams);
    break;
    }
    case CONST.IOU.ACTION_PARAMS.START_SPLIT_BILL: {
    dismissError();
    const startSplitBillParams = {...retryParams} as IOU.StartSplitBilActionParams;
    startSplitBillParams.receipt = file;
    startSplitBillParams.shouldPlaySound = false;
    startSplitBill(startSplitBillParams);
    break;
    }
    case CONST.IOU.ACTION_PARAMS.TRACK_EXPENSE: {
    dismissError();
    const trackExpenseParams = {...retryParams} as IOU.CreateTrackExpenseParams;
    trackExpenseParams.transactionParams.receipt = file;
    trackExpenseParams.isRetry = true;
    trackExpenseParams.shouldPlaySound = false;
    IOU.trackExpense(trackExpenseParams);
    break;
    }
    case CONST.IOU.ACTION_PARAMS.MONEY_REQUEST: {
    dismissError();
    const requestMoneyParams = {...retryParams} as IOU.RequestMoneyInformation;
    requestMoneyParams.transactionParams.receipt = file;
    requestMoneyParams.isRetry = true;
    requestMoneyParams.shouldPlaySound = false;
    IOU.requestMoney(requestMoneyParams);

    For scan expenses in pending ADD state, that dismiss path is destructive. dismissReceiptError() enters the pendingAction === ADD branch and can call cleanUpMoneyRequest(...), deleting the transaction/report context and navigating away:

    if (transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) {
    if (chatReport?.reportID && getCreationReportErrors(chatReport)) {
    navigateToConciergeChatAndDeleteReport(chatReport.reportID, conciergeReportID, true, true);
    return;
    }
    if (parentReportAction) {
    cleanUpMoneyRequest(
    transaction?.transactionID ?? linkedTransactionID,
    parentReportAction,
    report.reportID,
    iouReport,
    chatIOUReport,
    isChatIOUReportArchived,
    originalReportID,
    true,
    );
    return;
    }

    So the user leaves the expense before the retry failure can surface.

    A second issue is that the retried request was not fully preserving the original transaction context, so the next failure could be written to a fresh optimistic transaction instead of the one the current expense page was rendering. That caused the original error to disappear without showing the new failure on the same expense.

    A smaller, secondary issue is that the generic confirm modal triggered from DotIndicatorMessage uses useConfirmModal(), which defaults shouldHandleNavigationBack to true. For this retry-failure modal we should explicitly disable that behavior to avoid unintended navigation.

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

    Use a non-destructive retry flow and preserve the original transaction identity all the way through retry.

    1. Stop calling full dismissError() in handleFileRetry() for retryable actions.
    2. Clear only transaction error state with Transaction.clearError() before retrying.
    3. Preserve context by including transactionID in the receipt-error payload created by getReceiptError(...).
    4. Preserve the original transaction object in retry params so retry failures bind back to the same expense:
      • retryParams.existingTransactionDraft = optimisticTransaction for requestMoney
      • retryParams.existingTransaction = optimisticTransaction for trackExpense
    5. Keep destructive dismiss behavior only for explicit user dismissal, not retry.
    6. Add shouldHandleNavigationBack: false to the retry-failure confirm modal in DotIndicatorMessage as a safeguard.

    Concrete changes

    1. Non-destructive retry in handleFileRetry.ts

    Replace dismissError() with a helper that clears only the transaction error when a transaction ID is available.

    Key behavior:

    • use message.transactionID
    • for REPLACE_RECEIPT, allow fallback to retryParams.transactionID
    • only call dismissError() in non-retry/default fallback paths

    2. Extend ReceiptError in Transaction.ts

    type ReceiptError = {
        source: string;
        filename: string;
        action: string;
        retryParams: StartSplitBilActionParams | CreateTrackExpenseParams | RequestMoneyInformation | ReplaceReceipt;
        transactionID?: string;
        error: typeof CONST.IOU.RECEIPT_ERROR;
    };

    3. Thread transactionID through receipt error creation in IOU/index.ts

    Update getReceiptError() to accept transactionID and include it in the payload.

    Pass transaction.transactionID or transactionID to getReceiptError() for:

    • money request receipt error writes
    • track expense receipt error writes
    • replace receipt failure writes

    4. Preserve original transaction in retry params

    After building the optimistic transaction used for the current expense, store it back into retry params before those params are serialized into the receipt error payload:

    • in requestMoney():
    retryParams.existingTransactionDraft = optimisticTransaction;
    • in trackExpense():
    retryParams.existingTransaction = optimisticTransaction;

    This ensures the retried request reuses the same transaction context, so the next failure appears on the expense the user is viewing.

    5. Modal safeguard in DotIndicatorMessage.tsx

    showConfirmModal({
        prompt: translate('common.genericErrorMessage'),
        confirmText: translate('common.ok'),
        shouldShowCancelButton: false,
        shouldHandleNavigationBack: false,
    });

    This is a secondary safeguard for the generic retry-failure modal path.

    What alternative solutions did you explore? (Optional)

    1. Setting only shouldHandleNavigationBack: false in DotIndicatorMessage.
      This helps modal behavior, but does not fix destructive cleanup during retry or the lost transaction context.

    2. Changing the default in useConfirmModal.
      Too broad and risky for unrelated modals.

    3. Passing a retry flag into dismissReceiptError.
      Possible, but it mixes retry-specific behavior into a general dismiss function and is less clean than making retry non-destructive by design.

    4. Keeping the non-destructive retry fix without preserving existingTransaction / existingTransactionDraft.
      This prevents navigation away, but can still cause the next failure to disappear from the current expense because the retry may bind to a new optimistic transaction.

  11. 36 remaining items

  12. melvin-bot commented on Apr 23, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @blimpich, @stephanieelliott, @DylanDylann eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  13. twilight2294 commented on Apr 24, 2026

    @twilight2294
    Contributor

    @DylanDylann can you please review my proposal thanks !

  14. eh2077 commented on Apr 24, 2026

    @eh2077
    Contributor

    @MelvinBot Please reassign me as C+ as discussed in slack

  15. situchan commented on Apr 24, 2026

    @situchan
    Contributor

    @OlimpiaZurek should this be handled as part of #69669?

  16. OlimpiaZurek commented on Apr 24, 2026

    @OlimpiaZurek
    Contributor

    I think this can be handled as part of this issue, since the current discussion suggests the retry mechanism will be modified and the ‘Try again’ button will likely be dropped

  17. DylanDylann commented on Jun 15, 2026

    @DylanDylann
    Contributor

    Could someone please reassign this issue to @getusha for follow-up?

  18. getusha commented on Aug 27, 2026

    @getusha
    Contributor

    @situchan is this handled?

  19. situchan commented on Aug 27, 2026

    @situchan
    Contributor

    yes

  20. getusha commented on Aug 27, 2026

    @getusha
    Contributor

    @blimpich @mallenexpensify we can close this!

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.ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions