Skip to content

[Odometer] Reloading app during creation flow with preview open lands on not-found page #81901

Closed

Description

@Julesssss

Part of the Migrate Odometer project.

When the app is reloaded while a preview is open during the expense creation flow (before a recipient has been chosen), the user lands on a not-found page.

Root cause: On reload the app attempts to rebuild the URL. When it lacks the fullscreen screen it falls back to adding a screen based on the reportID. During the creation flow, before a recipient is selected, the reportID is a temporary/fake value. This causes navigation to resolve to a non-existent report, resulting in the not-found page.

Expected behavior: Close the preview and navigate to the home page. The preview data is a draft with no persisted state, so there is nothing to restore. This is consistent with how every other expense type already behaves on reload.

Proposed fix: Detect the temporary reportID case during URL reconstruction and, instead of attempting to navigate to the report, dismiss the preview and land on the home page.

Activity

  1. self-assigned this
    on Feb 9, 2026
  2. added
    ImprovementItem broken or needs improvement.
    InternalRequires API changes or must be handled by Expensify staff
    on Feb 9, 2026
  3. MelvinBot commented on Feb 13, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When the app is reloaded while a receipt/odometer preview is open during the expense creation flow (before a recipient has been chosen), the user lands on a not-found page instead of being gracefully returned to the home page.

    What is the root cause of that problem?

    The root cause is that TransactionReceiptModalContent shows a not-found page when the draft transaction is unavailable after reload, combined with the navigation layer not having special handling for creation-flow URLs with temporary reportIDs.

    Here is the specific chain of events:

    1. Temporary reportID in URL: When the user starts an expense from the global FAB, FloatingActionButtonAndPopover generates a random reportID via generateReportID() (src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx:196). This reportID is embedded in the navigation URL but never persisted to Onyx as a real report.

    2. RECEIPT_PREVIEW is a root-level screen: The MONEY_REQUEST.RECEIPT_PREVIEW screen is registered at the root level of the navigation stack (src/libs/Navigation/AppNavigator/AuthScreens.tsx:636-641 and src/libs/Navigation/linkingConfig/config.ts:36), not inside the RHP. Its route pattern is :action/:iouType/receipt/:transactionID/:reportID/:imageType?.

    3. Navigation state reconstruction: On reload, getAdaptedStateFromPath (src/libs/Navigation/helpers/getAdaptedStateFromPath.ts:217-262) finds no fullscreen route in the parsed state. It calls getMatchingFullScreenRoute, but RECEIPT_PREVIEW has no RHP_TO_* mapping. It falls back to getDefaultFullScreenRoute (line 179-199), which checks the reportID against Onyx -- the temporary ID has no entry, so it returns a generic REPORTS_SPLIT_NAVIGATOR.

    4. Component-level not-found: TransactionReceiptModalContent (src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx:55,208-209) determines isDraftTransaction = !!action (which is true since action = "create" from the URL). For draft transactions, shouldShowNotFoundPage simplifies to !transaction. The transaction is read from TRANSACTION_DRAFT Onyx key. If the draft is unavailable or has invalid blob:// receipt URLs after reload, the not-found page is shown.

    Why other expense types handle this correctly: The IOURequestStartPage uses AccessOrNotFoundWrapper which explicitly detects the global-create case via isFromGlobalCreate = isEmptyObject(report?.reportID) (src/pages/workspace/AccessOrNotFoundWrapper.tsx:156) and bypasses the not-found guard. The receipt preview screen has no equivalent bypass.

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

    In TransactionReceiptModalContent, when isDraftTransaction is true and the transaction draft is not available (i.e., transactionDraft is null/undefined after reload), instead of showing the not-found page, dismiss the preview and navigate to the home page. This can be done by adding an effect that checks for this condition and calls Navigation.dismissModal() followed by Navigation.navigateHome() (or equivalent), similar to how other creation-flow screens handle the reload case.

    Specifically, in src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx, add a check early in the component: if isDraftTransaction is true and transactionDraft is null/undefined, navigate away instead of rendering the not-found view. This is consistent with the issue's expected behavior ("close the preview and navigate to the home page") and aligns with how every other expense type already behaves on reload -- the preview data is a draft with no persisted state, so there is nothing to restore.

    What alternative solutions did you explore? (Optional)

    An alternative would be to handle this at the navigation layer in getAdaptedStateFromPath by detecting that the URL corresponds to a creation-flow receipt preview (checking action === 'create' in the route params) and redirecting to the home screen. However, this would be more invasive and the component-level fix is simpler, more targeted, and consistent with the existing pattern where individual screens handle their own reload recovery.

    Another alternative would be to add an isFromGlobalCreate bypass to withWritableReportOrNotFound (similar to what AccessOrNotFoundWrapper does), but this wouldn't help for RECEIPT_PREVIEW since it doesn't use that HOC -- it renders via TransactionReceiptModalContent directly.


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

  4. 3 remaining items

  5. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #84001
    Please mark it as "Ready for review" when it is ready for review.

  6. DylanDylann commented on Mar 5, 2026

    @DylanDylann
    Contributor

    This should be held as discussed on Slack thread

  7. changed the title [-][Odometer] Reloading app during creation flow with preview open lands on not-found page[/-] [+][HOLD][Odometer] Reloading app during creation flow with preview open lands on not-found page[/+] on Mar 5, 2026
  8. jakubkalinski0 commented on Mar 10, 2026

    @jakubkalinski0
    Member

    I will be taking care of this issue next

  9. changed the title [-][HOLD][Odometer] Reloading app during creation flow with preview open lands on not-found page[/-] [+][Odometer] Reloading app during creation flow with preview open lands on not-found page[/+] on Mar 16, 2026
  10. DylanDylann commented on Mar 19, 2026

    @DylanDylann
    Contributor

    @jakubkalinski0 Any update here?

  11. Julesssss commented on Mar 19, 2026

    @Julesssss
    ContributorAuthor

    This is lower priority than the currently in progress bugs. But would be a good bug to pickup next week.

  12. jakubkalinski0 commented on Mar 26, 2026

    @jakubkalinski0
    Member

    @jakubkalinski0 Any update here?

    Sorry for missing that message, I was focused on those three PRs:

    But I did come back to this issue yesterday and today to investigate if there is some better fix than the one left on this older draft PR #82407. What's pretty confusing/interesting to me is that the issue seems to disappear completely 😅. There were some significant changes made to the state restoration logic which I am now looking into in parallel to answering review on those PRs above. I want to make sure that the issue is definitely fixed and properly test that.

  13. jakubkalinski0 commented on Mar 27, 2026

    @jakubkalinski0
    Member

    @Julesssss @DylanDylann Some good news here!
    This bug is no more 🎉 It's all due to this change made in getDefaultFullScreenRoute:

    Detailed explanation
    getDefaultFullScreenRoute:

    // If there is no particular matching route defined, we want to get the default route.
    // It is the reports split navigator with report. If the reportID is defined in the focused route, we want to use it for the default report.
    // This is separated from getMatchingFullScreenRoute because we want to use it only for the initial state.
    // We don't want to make this route mandatory e.g. after deep linking or opening a specific flow.
    function getDefaultFullScreenRoute(route?: NavigationPartialRoute) {
    if (route && isRouteWithReportID(route)) {
    const reportID = route.params.reportID;
    // Only allReports should be checked here
    if (!getReportOrDraftReport(reportID, undefined, undefined, {})) {
    return {name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR};
    }
    return getInitialSplitNavigatorState(
    {
    name: SCREENS.INBOX,
    },
    {
    name: SCREENS.REPORT,
    params: {reportID},
    },
    );
    }
    return {name: SCREENS.HOME};
    }

    specifically this change below is crucial as it defaults to NAVIGATORS.REPORTS_SPLIT_NAVIGATOR when reportID cannot be found in ONYX, which is our case during creation flow before we choose the recipient.

    crucial change:

    if (!getReportOrDraftReport(reportID, undefined, undefined, {})) {
    return {name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR};
    }

    Video proof from current main with comparison to the Scan receipt preview:
    main.mov

    Issue 1

    As you can see in the video above the only issue left is that we don't yet detect faulty blob URLs so when we reload on image preview open our rebuild state lands on the TransactionReceiptModalContent with infinite loading indicator. But this issue will be solved in our next PR:

    Issue 2

    Also you could see on the video that when we reload on Scan image preview then the RHP stays open and for odometer that doesn't happen but that's actually caused by the blob URL loss detection mechanism, not the state restoration. When faulty blob URL is detected then navigateToStartMoneyRequestStep is called and thus we once again land on the open RHP with Scan screen visible.

    Video showing that when we reload on Scan receipt preview on mobile then blob URL loss detection doesn't bring us back to RHP Scan screen as there are bo blob URLs(proof that the RHP Scan we see on mobile after reload is owed to blob URL loss detection):
    proof-of-no-RHP-scan-recovery.mp4

    Good news once again! This will also be solved here:

    Video showing how it works after we introduce blob URL loss detection to odometer (with comparison to Scan)
    blob-url-verification.mov

    TLDR

    Two small differences between Odometer and Scan are caused by the lack of blob URL loss detection for Odometer so this will be taken care off in our next PR:

    Besides that we are good!


    Due to that I would like to close this old PR

    and I think we can also close this issue. What do you think about that? Also feel free to give any feedback or ask questions!

  14. Julesssss commented on Mar 28, 2026

    @Julesssss
    ContributorAuthor

    Nice! That's great news.

  15. DylanDylann commented on Apr 3, 2026

    @DylanDylann
    Contributor

    @Julesssss Could you close this issue?

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

Metadata

Metadata

Labels

EngineeringImprovementItem broken or needs improvement.InternalRequires API changes or must be handled by Expensify staffWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions