You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Scan-Error modal is not displayed when Retry fails #83537
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:
Open the Expensify app
Go to Troubleshoot > Enable Simulate failing network requests
Create a scan expense
Go to the expense details
Wait until the error message appears
Tap "Retry" link
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.
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
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:
User taps "Retry" → handleRetryPress in ReceiptUploadRetryHandler attempts to reconstruct the receipt file from local storage
On Android (index.android.ts), RNFS reads the local file; on iOS (index.ts), fetch(message.source) is called
If file reconstruction fails, the error modal callback is triggered (this is the modal the issue is about)
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:
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)
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.
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.
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)
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.
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.
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:
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.
Stop calling full dismissError() in handleFileRetry() for retryable actions.
Clear only transaction error state with Transaction.clearError() before retrying.
Preserve context by including transactionID in the receipt-error payload created by getReceiptError(...).
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
Keep destructive dismiss behavior only for explicit user dismissal, not retry.
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
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:
This is a secondary safeguard for the generic retry-failure modal path.
What alternative solutions did you explore? (Optional)
Setting only shouldHandleNavigationBack: false in DotIndicatorMessage.
This helps modal behavior, but does not fix destructive cleanup during retry or the lost transaction context.
Changing the default in useConfirmModal.
Too broad and risky for unrelated modals.
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.
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.
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!
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
Activity
melvin-bot commentedon Feb 26, 2026
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.melvin-bot commentedon Feb 26, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (
External)melvin-bot commentedon Feb 26, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022026910439458013314
[-]Scan-Error modal is not displayed when Retry fails[/-][+][$250] Scan-Error modal is not displayed when Retry fails[/+]MelvinBot commentedon Feb 26, 2026
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.tsxto replace an inline<ConfirmModal>component (controlled by localuseState) with theuseConfirmModalhook from the global modal system. This introduced a behavioral change:The
shouldHandleNavigationBack: truedefault: Insrc/hooks/useConfirmModal.ts:14, the hook always setsshouldHandleNavigationBack: trueas a default prop when showing modals. The old inlineConfirmModalinDotIndicatorMessagedid not have this prop set (defaulting toundefined/false).The retry flow works as follows:
handleRetryPressinReceiptUploadRetryHandlerattempts to reconstruct the receipt file from local storageindex.android.ts), RNFS reads the local file; on iOS (index.ts),fetch(message.source)is calledhandleFileRetrycallsdismissError()and re-dispatches the IOU action — no modal is shownWhen file reconstruction fails and the modal callback IS triggered, the new code calls
showConfirmModal()which renders via the globalModalProviderat the app root level withshouldHandleNavigationBack: true. On web, this causeswindow.history.back()when the modal is dismissed, potentially navigating the user away. On native, this prop is not consumed byBaseModaldirectly but may affect the modal lifecycle through theConfirmModalWrapperbridge component.The old inline
ConfirmModalwas rendered withinDotIndicatorMessage's component tree and was always present in the DOM (just toggled viaisVisible). The new approach mounts a freshConfirmModalWrapperinto theModalProvideronly 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, passshouldHandleNavigationBack: falsein theshowConfirmModalcall to match the old inlineConfirmModalbehavior: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
DotIndicatorMessageshould be reverted to use an inlineConfirmModalwith localuseState(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)
useConfirmModal.tstoshouldHandleNavigationBack: false— this would affect all consumers of the hook and might break other modals that rely on the navigation back behavior.ModalProviderrendering on native — the global modal system renders viaModalProviderat the app root. If there are issues with howConfirmModalWrapperrenders 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 thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.twilight2294 commentedon Feb 26, 2026
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 callsdismissError()before re-dispatching the IOU action. ThedismissErrorcallback originates fromdismissReceiptError()in MoneyRequestReceiptView.When
transaction?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,dismissReceiptError()callscleanUpMoneyRequest(), 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()(ortrackExpense()) 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 bycleanUpMoneyRequest()), so they never see the new error or the scan-error modal. The modal callback passed assetShouldShowErrorModalin 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
shouldHandleNavigationBackin theuseConfirmModalhook. 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 triggerscleanUpMoneyRequestand navigates away), we should only clear the transaction errors. We can useTransaction.clearError()to remove the error from the transaction without destroying the entire money request context:The
transactionIDcan be obtained from theretryParams(already available asretryParams.transactionParams.transactionID) and threaded through from DotIndicatorMessage wherereceiptErroralready 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)
Adding a
isRetryflag todismissReceiptError— This would skip thecleanUpMoneyRequestpath 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.Calling
Onyx.mergedirectly to clear just the transaction errors — This would work but using the existingTransaction.clearError()action is more consistent with the codebase patterns.marufsharifi commentedon Feb 26, 2026
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:
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 calleddismissError()before re-dispatching retry actions (requestMoney,trackExpense, etc.):App/src/libs/ReceiptUploadRetryHandler/handleFileRetry.ts
Lines 13 to 43 in a152afa
For scan expenses in pending
ADDstate, that dismiss path is destructive.dismissReceiptError()enters thependingAction === ADDbranch and can callcleanUpMoneyRequest(...), deleting the transaction/report context and navigating away:App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Lines 267 to 284 in a152afa
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
DotIndicatorMessageusesuseConfirmModal(), which defaultsshouldHandleNavigationBacktotrue. 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.
dismissError()inhandleFileRetry()for retryable actions.Transaction.clearError()before retrying.transactionIDin the receipt-error payload created bygetReceiptError(...).retryParams.existingTransactionDraft = optimisticTransactionforrequestMoneyretryParams.existingTransaction = optimisticTransactionfortrackExpenseshouldHandleNavigationBack: falseto the retry-failure confirm modal inDotIndicatorMessageas a safeguard.Concrete changes
1. Non-destructive retry in
handleFileRetry.tsReplace
dismissError()with a helper that clears only the transaction error when a transaction ID is available.Key behavior:
message.transactionIDREPLACE_RECEIPT, allow fallback toretryParams.transactionIDdismissError()in non-retry/default fallback paths2. Extend
ReceiptErrorinTransaction.ts3. Thread
transactionIDthrough receipt error creation inIOU/index.tsUpdate
getReceiptError()to accepttransactionIDand include it in the payload.Pass
transaction.transactionIDortransactionIDtogetReceiptError()for: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:
requestMoney():trackExpense():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.tsxThis is a secondary safeguard for the generic retry-failure modal path.
What alternative solutions did you explore? (Optional)
Setting only
shouldHandleNavigationBack: falseinDotIndicatorMessage.This helps modal behavior, but does not fix destructive cleanup during retry or the lost transaction context.
Changing the default in
useConfirmModal.Too broad and risky for unrelated modals.
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.
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.
36 remaining items
melvin-bot commentedon Apr 23, 2026
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!
twilight2294 commentedon Apr 24, 2026
@DylanDylann can you please review my proposal thanks !
eh2077 commentedon Apr 24, 2026
@MelvinBot Please reassign me as C+ as discussed in slack
situchan commentedon Apr 24, 2026
@OlimpiaZurek should this be handled as part of #69669?
OlimpiaZurek commentedon Apr 24, 2026
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
DylanDylann commentedon Jun 15, 2026
Could someone please reassign this issue to @getusha for follow-up?
getusha commentedon Aug 27, 2026
@situchan is this handled?
situchan commentedon Aug 27, 2026
yes
getusha commentedon Aug 27, 2026
@blimpich @mallenexpensify we can close this!