Skip to content

[Odometer] [$250] Capture an image in Odometer user is redirected back to Inbox #83526

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: 9.3.26-4
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82432
Email or phone of affected tester (no customers): applausetester+dk10@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: iPhone 11/iOS26.3
App Component: Money Requests

Action Performed:

Preconditions:

  • Use Expensifail account
  • Fresh install app or disable camera permission for Expensify in Settings
  1. Open Native app
  2. Tap on FAB > Track distance
  3. Tap on Odometer tab
  4. Tap on Thumbnail in 'Start reading' or 'End reading'
  5. Tap on 'Continue' button
  6. Tap on 'Don't allow'
  7. On the new prompt, tap on 'Settings'
  8. Enable Camera on the Settings page for Expensify
  9. Navigate back to App, it should stay in Camera page
  10. Capture the photo

Expected Result:

User is redirected back to Odometer page

Actual Result:

User is redirected back to Inbox page

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7088840_1772076878239.Odometer.mp4

View all open jobs on GitHub

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

Activity

  1. added
    DeployBlockerCash
    on Feb 26, 2026
  2. added
    Daily
    Bug
    DeployBlocker
    on Feb 26, 2026
  3. melvin-bot commented on Feb 26, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 26, 2026

    @melvin-bot

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

  5. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (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.

  6. github-actions commented on Feb 26, 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.
  7. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

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

    On iOS, when a user is on the Odometer image capture screen and denies camera permission, then navigates to iOS Settings to enable it and returns to the app, capturing a photo redirects them to the Inbox instead of back to the Odometer page.

    What is the root cause of that problem?

    On iOS, toggling camera permission in Settings can cause the OS to evict the app's nested React Navigation state from memory. When the user returns, the ReportsSplitNavigator route still exists at the root level, but its .state property (containing the nested screen stack) becomes undefined.

    The IOURequestStepOdometerImage native component calls Navigation.goBack() with no fallback route after photo capture (index.native.tsx:98-100):

    const navigateBack = () => {
        Navigation.goBack();
    };

    With the navigation state lost, goBack() has nowhere meaningful to return to, so React Navigation falls back to the root screen (Inbox).

    This exact same bug was already identified and fixed for IOURequestStepScan in #65992. The Scan component detects the lost state and explicitly navigates to a fallback route instead of calling goBack() (IOURequestStepScan/index.native.tsx:231-249):

    const navigationState = navigationRef.current?.getState();
    const reportsSplitNavigator = navigationState?.routes?.findLast(
        (route) => route.name === 'ReportsSplitNavigator'
    );
    const hasLostNavigationsState = reportsSplitNavigator && !reportsSplitNavigator.state;
    if (hasLostNavigationsState) {
        Navigation.navigate(backTo ?? ROUTES.INBOX);
    } else {
        navigateBack();
    }

    The IOURequestStepOdometerImage component is missing this guard entirely.

    Additionally, the web version of the same component (index.tsx:56-60) correctly passes a fallback route to Navigation.goBack(), while the native version does not.

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

    In src/pages/iou/request/step/IOURequestStepOdometerImage/index.native.tsx:

    1. Add the navigation-state-loss detection from IOURequestStepScan to the navigateBack / photo capture flow. Before calling Navigation.goBack(), check if ReportsSplitNavigator has lost its nested state. If so, navigate explicitly to the odometer route (using ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(...)) instead of calling goBack().

    2. Destructure reportID from route params (currently missing at line 66-67, but present in the web version at line 34) so the fallback odometer route can be constructed.

    3. Wrap the useFocusEffect callback in useCallback (line 145) to match the pattern used in IOURequestStepScan (line 200-228), preventing unnecessary teardown/setup cycles of the AppState listener on each render.

    What alternative solutions did you explore? (Optional)

    • Passing odometerRoute to Navigation.goBack() as a fallback (like the web version does): This alone may not be sufficient because goBack() with a backToRoute calls goUp(), which still relies on the navigation state being intact to locate the target screen. The explicit lost-state check from IOURequestStepScan is the more robust approach.
    • Fixing this at the Navigation.goBack() level globally: While this would prevent similar bugs in other screens, it would be a larger change with higher risk. The per-component fix matches the existing pattern and is safer for a deploy blocker.

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

  8. 27 remaining items

  9. jakubkalinski0 commented on Mar 5, 2026

    @jakubkalinski0
    Member

    This issue seems to be present not only on native but also also on web and is also present even without reloading the App (not the exact same issue but the variation of this) and all of that is caused purely by bad back navigation. Current implementation on native works fine before App reload as it simply moves to the previous screen on stack but loses that information when we reload the App hence we land on inbox. In case of web implementation we are always brought back to odometer tab, so when we take photo from confirmation page -> distance -> replace/take photo we are still brought back to odometer tab instead of distance. Because of that this issue has to be merged before we can go ahead with testing the image stitching feature as it makes it impossible to test if images are properly stitched when replaced from confirmation page.

    const odometerRoute = ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(action, iouType, transactionID, reportID);
    const navigateBack = () => {
    Navigation.goBack(odometerRoute);
    };

    const navigateBack = () => {
    Navigation.goBack();
    };

  10. Julesssss commented on Mar 5, 2026

    @Julesssss
    Contributor

    Current implementation on native works fine before App reload

    To confirm, it occurs in other flows after refreshing. But for this case it occurs without a refresh?

  11. jakubkalinski0 commented on Mar 5, 2026

    @jakubkalinski0
    Member

    @Julesssss Maybe it will be simpler if I break it down case by case to fully explain it.

    • Current native implementation:

    const navigateBack = () => {
    Navigation.goBack();
    };

    1. It works without refresh
    That's because we simply go back on the screen stack to the screen before. This means that we don't have to recognize where we came from. Flows case by case:

    flow 1
    odometer tab -> thumbnail -> odometerImage screen -> take photo -> we go back to the previous screen on stack so we land on odometer tab
    
    flow 2
    fill out values on odometer tab -> confirmation page -> distance -> thumbnail -> odometerImage screen -> take photo -> we go back to the previous screen on stack so we land on distance
    

    2. It doesn't work after refresh
    After refresh the screen stack is cleared and we have nowhere to go thus we default back to inbox

    • Current web implementation:

    const odometerRoute = ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER.getRoute(action, iouType, transactionID, reportID);
    const navigateBack = () => {
    Navigation.goBack(odometerRoute);
    };

    1. It works without refresh but only on odometer tab
    We always go back to ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER so when we take a photo from odometer tab we properly navigate back to the odometer tab.

    2. It works with refresh but only on odometer tab
    We always go back to ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER so when we go to the odometer image screen from odometer tab and reload then we properly navigate back to the odometer tab.

    3. It newer works when we go confirmation -> distance -> take photo
    Thats because we always go back to ROUTES.DISTANCE_REQUEST_CREATE_TAB_ODOMETER so it doesn't matter whether we refreshed or not. After we take the photo this is called

     const navigateBack = () => { 
         Navigation.goBack(odometerRoute); 
     };
    

    and we land on odometer tab -> thus it's always wrong.

  12. jakubkalinski0 commented on Mar 5, 2026

    @jakubkalinski0
    Member

    I hope that clears it up

  13. added
    Reviewing
    Weekly
    and removed
    Daily
    on Mar 5, 2026
  14. Julesssss commented on Mar 6, 2026

    @Julesssss
    Contributor

    Thanks for detailed explanation @jakubkalinski0. So it sounds like we shouldadd loss-detection detection (similar to IOURequestStepScan), And then as you mentioned, expand this to solve for web too?

  15. Julesssss commented on Mar 9, 2026

    @Julesssss
    Contributor

    PR merged. #83668

  16. Julesssss commented on Mar 9, 2026

    @Julesssss
    Contributor

    No payment required, it'll be bundled here.

  17. jakubkalinski0 commented on Mar 12, 2026

    @jakubkalinski0
    Member

    Thanks for detailed explanation @jakubkalinski0. So it sounds like we shouldadd loss-detection detection (similar to IOURequestStepScan), And then as you mentioned, expand this to solve for web too?

    For anybody interested this was discussed and resolved on a private conversation on slack.

  18. Julesssss commented on Mar 12, 2026

    @Julesssss
    Contributor

    Deployed to prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringExternalImprovementReviewingWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions