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
Block tab navigation while photo capture is in progress #83949
When the scan receipt camera is open and a user taps the shutter button, then immediately taps the Manual tab, the app navigates away from the scan view while the photo capture is still in progress. This can lead to unexpected behavior since the capture flow is interrupted mid-flight.
Solution
Disable tab navigation (Scan/Manual/Distance) while a photo capture is in progress. Once the capture completes (or fails), re-enable tab switching.
Determine how to signal from the scan component to the OnyxTabNavigator/TabSelector that tab switching should be blocked
One approach: store a capture-in-progress flag in Onyx that the TabSelector reads to ignore taps
Another approach: add a disabled prop to OnyxTabNavigator or TabSelector
Unblock navigation once capture resolves or errors
Please re-state the problem that we are trying to solve in this issue.
When the scan receipt camera is open and a user taps the shutter button, then immediately taps the Manual tab, the app navigates away from the scan view while the photo capture is still in progress. This causes unexpected behavior because initMoneyRequest() resets the transaction draft while the async camera capture is still in flight, and when the capture completes, it tries to set receipt data on a reset transaction and may trigger navigation to the confirmation step even though the user has already switched tabs.
What is the root cause of that problem?
Tab switching in IOURequestStartPage is completely unguarded — there is no check for whether a photo capture is in progress before allowing the tab to change.
The race condition works as follows:
User taps the shutter button → capturePhoto() in index.native.tsx:302 sets didCapturePhoto = true (line 343) and calls camera.current.takePhoto() which returns a Promise (line 362-367)
Before the Promise resolves, user taps the Manual tab
TabSelector.handleTabPress() in TabSelector.tsx:37-58 dispatches TabActions.jumpTo() with no guard
OnyxTabNavigator's state listener fires → onTabSelected() → resetIOUTypeIfChanged() → initMoneyRequest() in IOURequestStartPage.tsx:178-226
initMoneyRequest() calls removeDraftTransactions() and resets the transaction draft via Onyx.set() in IOU/index.ts:1242,1333
Eventually, takePhoto() resolves and tries to set receipt data on the now-reset transaction, and submitReceipts() triggers navigation to the confirmation step
The didCapturePhoto state at index.native.tsx:91 is entirely local to IOURequestStepScan — it is never communicated to the parent IOURequestStartPage that controls tab switching. It is only used to prevent double-tapping the shutter and to disable the multi-scan submit button in ReceiptPreviews.
The web version (index.tsx) has no didCapturePhoto state at all, though the synchronous getScreenshot() call makes the window for this race smaller on web.
What changes do you think we should make in order to solve the problem?
Use the existing screenListeners + canPreventDefault pattern that React Navigation and TabSelector already support:
Lift the capture-in-progress state from IOURequestStepScan up to IOURequestStartPage. Pass a setIsCapturingPhoto callback down to IOURequestStepScan (similar to the existing setIsMultiScanEnabled pattern). Set it to true when capture begins and false when capture completes or fails.
Add a screenListeners prop to the OnyxTabNavigator in IOURequestStartPage with a tabPress event listener that calls e.preventDefault() when isCapturingPhoto is true. TabSelector.handleTabPress() already emits tabPress events with canPreventDefault: true (line 48-52) and only dispatches TabActions.jumpTo() if !event.defaultPrevented (line 54-55), so this will block the tab switch cleanly.
Add equivalent state tracking for web in index.tsx — wrap the async cropImageToAspectRatio call with a capture-in-progress flag.
This approach requires no changes to OnyxTabNavigator, TabSelector, or the navigation infrastructure — it only uses existing, supported patterns.
What alternative solutions did you explore? (Optional)
Storing a flag in Onyx: The issue description suggests storing a capture-in-progress flag in Onyx. This would work but is heavier than needed — the state is transient and only relevant to a single screen, so React state is more appropriate than persisted Onyx state.
Adding a disabled prop to TabSelectorItem: This would visually grey out the tabs, but TabSelector already has the canPreventDefault pattern built in, which is cleaner and doesn't require UI changes to the tab bar component.
Aborting the capture callback instead of blocking tabs: Rather than blocking the tab switch, we could check if the scan tab is still focused when the capture completes and bail out. This is more fragile and doesn't prevent the transaction reset from happening.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
Ha sorry @dubielzyk-expensify, I wasn't keeping eyes on this because I assumed Melvin was just rolling with it. Looks like the PR was merged so I think this one is done
Activity
melvin-bot commentedon Mar 2, 2026
Triggered auto assignment to @stephanieelliott (
NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO. Remember to draft any necessary HelpDot updates by following the instructions here.melvin-bot commentedon Mar 2, 2026
Triggered auto assignment to Design team member for new feature review - @dubielzyk-expensify (
NewFeature)MelvinBot commentedon Mar 2, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the scan receipt camera is open and a user taps the shutter button, then immediately taps the Manual tab, the app navigates away from the scan view while the photo capture is still in progress. This causes unexpected behavior because
initMoneyRequest()resets the transaction draft while the async camera capture is still in flight, and when the capture completes, it tries to set receipt data on a reset transaction and may trigger navigation to the confirmation step even though the user has already switched tabs.What is the root cause of that problem?
Tab switching in
IOURequestStartPageis completely unguarded — there is no check for whether a photo capture is in progress before allowing the tab to change.The race condition works as follows:
capturePhoto()inindex.native.tsx:302setsdidCapturePhoto = true(line 343) and callscamera.current.takePhoto()which returns a Promise (line 362-367)TabSelector.handleTabPress()inTabSelector.tsx:37-58dispatchesTabActions.jumpTo()with no guardOnyxTabNavigator's state listener fires →onTabSelected()→resetIOUTypeIfChanged()→initMoneyRequest()inIOURequestStartPage.tsx:178-226initMoneyRequest()callsremoveDraftTransactions()and resets the transaction draft viaOnyx.set()inIOU/index.ts:1242,1333takePhoto()resolves and tries to set receipt data on the now-reset transaction, andsubmitReceipts()triggers navigation to the confirmation stepThe
didCapturePhotostate atindex.native.tsx:91is entirely local toIOURequestStepScan— it is never communicated to the parentIOURequestStartPagethat controls tab switching. It is only used to prevent double-tapping the shutter and to disable the multi-scan submit button inReceiptPreviews.The web version (
index.tsx) has nodidCapturePhotostate at all, though the synchronousgetScreenshot()call makes the window for this race smaller on web.What changes do you think we should make in order to solve the problem?
Use the existing
screenListeners+canPreventDefaultpattern that React Navigation andTabSelectoralready support:Lift the capture-in-progress state from
IOURequestStepScanup toIOURequestStartPage. Pass asetIsCapturingPhotocallback down toIOURequestStepScan(similar to the existingsetIsMultiScanEnabledpattern). Set it totruewhen capture begins andfalsewhen capture completes or fails.Add a
screenListenersprop to theOnyxTabNavigatorinIOURequestStartPagewith atabPressevent listener that callse.preventDefault()whenisCapturingPhotoistrue.TabSelector.handleTabPress()already emitstabPressevents withcanPreventDefault: true(line 48-52) and only dispatchesTabActions.jumpTo()if!event.defaultPrevented(line 54-55), so this will block the tab switch cleanly.Add equivalent state tracking for web in
index.tsx— wrap the asynccropImageToAspectRatiocall with a capture-in-progress flag.This approach requires no changes to
OnyxTabNavigator,TabSelector, or the navigation infrastructure — it only uses existing, supported patterns.What alternative solutions did you explore? (Optional)
disabledprop toTabSelectorItem: This would visually grey out the tabs, butTabSelectoralready has thecanPreventDefaultpattern built in, which is cleaner and doesn't require UI changes to the tab bar component.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.dubielzyk-expensify commentedon Mar 3, 2026
Let me know if you need a mock or anything here, but I think simply disabling the tabs works 👍
melvin-bot commentedon Mar 6, 2026
@stephanieelliott, @dubielzyk-expensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
dubielzyk-expensify commentedon Mar 9, 2026
Not overdue
16 remaining items
dubielzyk-expensify commentedon Apr 1, 2026
Any updates here @marcaaron ?
melvin-bot commentedon Apr 7, 2026
@stephanieelliott, @dubielzyk-expensify Huh... This is 4 days overdue. Who can take care of this?
dubielzyk-expensify commentedon Apr 9, 2026
Any updates here?
dubielzyk-expensify commentedon Apr 14, 2026
Any updates? Been a few weeks without any updates now. Also looks like the PR for this merged anyways!?
dubielzyk-expensify commentedon Apr 17, 2026
@stephanieelliott ?
stephanieelliott commentedon Apr 17, 2026
Ha sorry @dubielzyk-expensify, I wasn't keeping eyes on this because I assumed Melvin was just rolling with it. Looks like the PR was merged so I think this one is done