App icon indicating copy to clipboard operation
App copied to clipboard

[$175] iOS Share Sheet - After adding an expense via the share sheet, user lands in the Inbox instead of the Spend page

Open m-natarajan opened this issue 1 week ago • 14 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.53-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @JmillsExpensify Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. On an iOS device, open a receipt/image in another app (e.g., Photos, Files).
  2. Tap Share and choose Expensify.
  3. Complete the flow to add/submit the expense.
  4. Observe where the app navigates after the expense is added.

Expected Result:

After the expense is added, the user is taken to the Spend page (Spend > Expenses), where the new expense is visible.

Actual Result:

The user lands in the Inbox.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome / Safari

Screenshots/Videos

https://github.com/user-attachments/assets/4f60545b-4cb1-40d6-bc09-d64761946681

View all open jobs on GitHub

Upwork Automation - Do Not Edit

m-natarajan avatar Nov 25 '26 14:11 m-natarajan

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

Job added to Upwork: https://www.upwork.com/jobs/~022125600564838801642

Proposal

What is the root cause of that problem?

The receipt submission flow explicitly selects a chat/report destination, which opens Inbox, rather than Spend > Expenses.

Confidence: Medium. Two independent code investigations support this explanation, but the native iOS flow was not reproduced. Web testing cannot reproduce the iOS system share sheet.

Code evidence and alternatives checked

This explains the navigation without requiring a timing failure or failed expense creation. Changing only the final cleanup would miss the explicit report-reveal branches.

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

Make successful receipt submission from the share sheet consistently select Spend > Expenses:

  • Use the existing Expenses destination for both pre-mounting and completion.
  • Remove report-arrival navigation waits where they are no longer necessary.
  • Preserve expense creation, cleanup, confirmation messaging, and cancellation behavior.
  • Leave the separate attachment/message-sharing flow unchanged.
Implementation reference and regression coverage

Reuse the canonical Expenses query and route construction in navigateAfterExpenseCreate.ts:105–140.

Update navigation tests to cover personal and workspace expenses, existing/new destination reports, narrow/wide layouts, and immediate submission before pre-mount completes. Verify cancellation and ordinary chat attachment sharing remain unchanged.

Native iOS verification should cover cold/warm launches and offline creation. The identified routing change is within App; no native repository change is currently indicated.

What alternative solutions did you explore? (Optional)

Marking the flow as “global create” or changing only cleanup navigation is insufficient: explicit report destinations would still select Inbox.


Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/107967) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 25 '26 14:11 MelvinBot

Proposal

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

After adding an expense via the iOS share sheet (share a receipt/image from another app → Expensify → complete the flow), the user lands in the Inbox instead of the Spend page (Spend > Expenses), where the new expense should be visible. Reproduced in staging and production on v9.5.53-2, iOS app.

What is the root cause of that problem?

The share flow's post-submit navigation always resolves to the destination report (chat), and the existing "route to Spend > Expenses" path is gated on an onboarding choice the share-sheet user never made.

Concretely, in src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts:86:

ts const isUserOnInbox = isReportTopmostSplitNavigator() && !(isLookingAroundUser && isSelfDMDestination);

The Spend routing (the navigateToSearch path below it, which navigates to ROUTES.SEARCH_ROOT with the expense query) only runs when the user picked the "Looking around / Something else" onboarding choice and the destination is their self-DM. SubmitDetailsPage.tsx:161 computes that flag as:

ts const isLookingAroundUser = isLookingAroundSearchRoutingActive(introSelected?.choice === CONST.ONBOARDING_CHOICES.LOOKING_AROUND, isOffline);

A share-sheet user with normal onboarding has isLookingAroundUser === false, so isUserOnInbox stays true and the function takes the early branch (dismissModalAndOpenReportInInboxTab(...), lines 90-96) — landing in the Inbox. The share page reinforces this: SubmitDetailsPage.tsx pre-mounts/reveals the report route (ROUTES.REPORT_WITH_ID, lines 359 and 572) as the post-submit destination, so there is no path that ever reaches Spend.

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

  1. Extend the Spend routing to the share-extension flow: pass an isShareFlow flag from SubmitDetailsPage.tsx through cleanupAndNavigateAfterExpenseCreate into navigateAfterExpenseCreate, and treat (isLookingAroundUser || isShareFlow) && isSelfDMDestination as "not on inbox", so the existing navigateToSearch path (Spend > Expenses) runs for self-DM share submissions. Scope it to the self-DM case exactly like the existing LOOKING_AROUND behavior, so submissions to real reports/friends keep their normal destination.
  2. In SubmitDetailsPage.tsx, skip the report-route pre-mount/reveal (ROUTES.REPORT_WITH_ID) for the self-DM share case, so the Search navigation is the one that wins.
  3. Add a unit test for navigateAfterExpenseCreate covering a share-flow self-DM expense create (expect navigation to SEARCH_ROOT with the expense query) and a regression test that a non-share, non-LOOKING_AROUND self-DM create still opens the report in the Inbox tab.

What alternative solutions did you explore? (Optional)

  • Navigating to ROUTES.SEARCH_ROOT directly in SubmitDetailsPage after submit: rejected — the shared helper (cleanupAndNavigateAfterExpenseCreate / navigateAfterExpenseCreate) already owns post-create navigation, including the modal-dismiss and telemetry handling; duplicating that in the share page would diverge the two flows.
  • Routing all share submissions to Spend regardless of destination: rejected — only the self-DM (track) case belongs in Spend; an expense submitted to a real workspace report should still open that report.

QA steps (to verify the fix)

  1. On iOS staging, open a receipt/image in Photos, tap Share → Expensify, complete the flow to add/submit the expense to your own account (self-DM).
  2. Verify you land on Spend > Expenses with the new expense visible — not in the Inbox.
  3. Repeat submitting an expense to a workspace report/friend via the share sheet and verify it still opens that report (no behavior change there).
  4. Regression-check the normal (non-share) expense create flow: a self-DM create by a non-LOOKING_AROUND user still opens the report in the Inbox tab.

Addendum — note on scope vs the implementation plan posted today: MelvinBot's plan routes every share-sheet submission (personal and workspace) to Spend and removes the report-arrival waits for the whole page. My proposal keeps the change scoped to the self-DM share flow (isShareFlow flag), leaving workspace/friend-DM destinations on their existing chat-report behavior and the shared helper's Inbox routing decisions untouched — which MelvinBot's own clarification also says should stay unchanged. It reuses the existing verified navigation path, fixing the reported bug without changing product behavior for other destinations.

letiggo avatar Nov 25 '26 21:11 letiggo

Proposal

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

On iOS devices, after adding or submitting an expense via the native system Share Sheet (sharing a receipt or image from an external app like Photos or Files), the user lands in the Inbox tab instead of being routed to the Spend page (Spend > Expenses), where the newly created expense should be visible.

What is the root cause of that problem?

There are two coupled defects causing the post-submit navigation to route to the Inbox tab:

1. SubmitDetailsPage.tsx hardcodes isFromGlobalCreate: false and canPreInsertSearch: false

In src/pages/Share/SubmitDetailsPage.tsx (lines 334–346):

const preMountDestinationRoute = getSubmitExpensePreMountDestinationRoute({
    isTransactionReady: hasNavigationDestination && !isDestinationReportMissing && !pendingNavigationReportID,
    destinationReportID: postSubmitNavigationReportID,
    destinationReport: destinationReportInCollection,
    isFromGlobalCreate: false,
    canPreInsertSearch: false,
    iouType,
    isCreatingTrackExpense,
    isSelfDMDestination: isSelfDM(report),
    isOptimisticNewChatDestination: false,
    isLookingAroundUser,
    isMovingTransactionFromTrackExpense: false,
});

And in lines 525–536:

const cleanupParams = {
    report: isSelfDM(report) ? report : reportToSubmit,
    action: CONST.IOU.ACTION.CREATE,
    draftTransactionIDs,
    transactionID: optimisticTransactionID,
    isFromGlobalCreate: getIsFromGlobalCreate(transaction),
    optimisticChatReportID: routeReportID,
    navigationReportID: postSubmitNavigationReportID,
    linkedTrackedExpenseReportAction: transaction.linkedTrackedExpenseReportAction,
    isLookingAroundUser,
    isSelfDMDestination: isSelfDM(report),
};

Because the Share Sheet transaction is constructed locally via initMoneyRequest and does not carry the isFromGlobalCreate flag, getIsFromGlobalCreate(transaction) returns false. Consequently:

  • canPreInsertSearch: false prevents getSubmitExpensePreMountDestinationRoute from pre-mounting Search (ROUTES.SEARCH_ROOT), falling back instead to pre-mounting ROUTES.REPORT_WITH_ID (the chat report in the Inbox).
  • On lines 568–579, if topmostReportId !== postSubmitNavigationReportID, it explicitly reveals ROUTES.REPORT_WITH_ID.getRoute(postSubmitNavigationReportID) over the modal, landing in the Inbox tab.

2. navigateAfterExpenseCreate.ts gates Search navigation on isFromGlobalCreate and isLookingAroundUser

In src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts (lines 86–98):

// Treat a LOOKING_AROUND user's self-DM create as "not on inbox" so it falls through to the Search navigation below
// (route to Spend > Expenses instead of Personal Space). Scoped to isSelfDMDestination so other destinations are unaffected.
const isUserOnInbox = isReportTopmostSplitNavigator() && !(isLookingAroundUser && isSelfDMDestination);

// If the expense is not created from global create or is currently on the inbox tab,
// we just need to dismiss the money request flow screens
// and open the report chat containing the IOU report
if (!isFromGlobalCreate || isUserOnInbox || !transactionID) {
    if (shouldNavigate) {
        dismissModalAndOpenReportInInboxTab(activeReportID, isInvoice, hasMultipleTransactions, transactionID);
    }
    if (shouldFlagNewTransactionForChatPreview) {
        flagNewTransactionForChatPreview({chatReportID: activeReportID, transactionID});
    }
    return;
}

If the app was open on the Inbox tab before the user switched to Photos to share a receipt:

  1. isReportTopmostSplitNavigator() evaluates to true.
  2. For normal onboarding users, isLookingAroundUser is false.
  3. Even if isFromGlobalCreate were true, isUserOnInbox evaluates to true.
  4. Therefore, !isFromGlobalCreate || isUserOnInbox evaluates to true, and line 93 unconditionally triggers dismissModalAndOpenReportInInboxTab, stranding the user in the Inbox!

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

1. Pass isShareFlow: true from SubmitDetailsPage.tsx

In src/pages/Share/SubmitDetailsPage.tsx:

  • When configuring getSubmitExpensePreMountDestinationRoute (lines 334–346), enable search pre-insertion for self-DM expenses:
const isSelfDMDestination = isSelfDM(report);
const preMountDestinationRoute = getSubmitExpensePreMountDestinationRoute({
    isTransactionReady: hasNavigationDestination && !isDestinationReportMissing && !pendingNavigationReportID,
    destinationReportID: postSubmitNavigationReportID,
    destinationReport: destinationReportInCollection,
    isFromGlobalCreate: isSelfDMDestination,
    canPreInsertSearch: isSelfDMDestination,
    iouType,
    isCreatingTrackExpense,
    isSelfDMDestination,
    isOptimisticNewChatDestination: false,
    isLookingAroundUser,
    isMovingTransactionFromTrackExpense: false,
});
  • In cleanupParams (line 525), pass isShareFlow: true and isFromGlobalCreate: isSelfDM(report) || getIsFromGlobalCreate(transaction).
  • On line 572, if topmostReportId !== postSubmitNavigationReportID and isSelfDMDestination:
const destinationRoute = isSelfDMDestination
    ? ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE}), searchKey: getSearchKeyForDataType(CONST.SEARCH.DATA_TYPES.EXPENSE)})
    : ROUTES.REPORT_WITH_ID.getRoute(postSubmitNavigationReportID);
Navigation.revealRouteBeforeDismissingModal(destinationRoute, {
    afterTransition: () => {
        cleanupAndNavigateAfterExpenseCreate({...cleanupParams, shouldNavigate: false});
        setIsConfirming(false);
    },
});

2. Support isShareFlow in navigateAfterExpenseCreate.ts

In src/libs/Navigation/helpers/navigateAfterExpenseCreate.ts:

  • Accept isShareFlow = false in NavigateAfterExpenseCreateParams.
  • Update isUserOnInbox calculation (line 86):
// Treat a LOOKING_AROUND user or Share Sheet submission for self-DM as "not on inbox" so it routes to Spend > Expenses
const isUserOnInbox = isReportTopmostSplitNavigator() && !((isLookingAroundUser || isShareFlow) && isSelfDMDestination);

This cleanly directs self-DM Share Sheet submissions to the Search/Spend navigator (ROUTES.SEARCH_ROOT with type: CONST.SEARCH.DATA_TYPES.EXPENSE), while leaving submissions to existing workspace chats or friend DMs to open their respective chat reports in the Inbox.

What alternative solutions did you explore (Optional)?

We considered calling Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute(...)) unconditionally in SubmitDetailsPage.tsx after expense creation. However, bypassing cleanupAndNavigateAfterExpenseCreate would discard telemetry tracking (setPendingSubmitFollowUpAction), omit modal dismissal transitions, and fail to handle submissions to existing workspace chat reports. Extending navigateAfterExpenseCreate ensures all shared post-create navigation guarantees are preserved across both normal and share extension workflows.

Automated Tests?

Yes, unit and UI tests added in:

  1. tests/unit/navigateAfterExpenseCreateTest.ts:
    • Verify that when isShareFlow: true and isSelfDMDestination: true, navigateAfterExpenseCreate routes to ROUTES.SEARCH_ROOT with the expense query even when isReportTopmostSplitNavigator() is true.
    • Verify that when isShareFlow: true but submitting to another user's chat or workspace report (isSelfDMDestination: false), it opens the report in the Inbox tab.
  2. tests/ui/SubmitDetailsPageTest.tsx:
    • Verify that submitting a receipt to self-DM passes isShareFlow: true to cleanupAndNavigateAfterExpenseCreate and pre-mounts ROUTES.SEARCH_ROOT.

kevinjosh10 avatar Nov 26 '26 04:11 kevinjosh10

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 26 '26 05:11 kevinjosh10

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 26 '26 05:11 melvin-bot[bot]

Proposal

What is the root cause of that problem?

SubmitDetailsPage explicitly routes every share-sheet expense submission to a chat/report screen inside the Inbox navigator instead of Spend > Expenses, across all four navigation paths:

  1. Pre-mount forces a report route: SubmitDetailsPage.tsx calls getSubmitExpensePreMountDestinationRoute with isFromGlobalCreate: false and canPreInsertSearch: false (SubmitDetailsPage.tsx:334-346). Even if those flags were enabled, getSubmitExpensePreMountDestinationRoute.ts:65 still blocks Search pre-insertion whenever isReportTopmostSplitNavigator() is true — the normal state on iOS when opening the Share Sheet from Inbox or cold launch.
  2. Pending-report and wide fallbacks hardcode ROUTES.REPORT_WITH_ID: Both revealPendingNavigation (SubmitDetailsPage.tsx:359) and the wide-layout fallback (SubmitDetailsPage.tsx:572) explicitly reveal ROUTES.REPORT_WITH_ID.
  3. Final cleanup fallback opens Inbox (and locks narrow tabs): cleanupParams passes isFromGlobalCreate: getIsFromGlobalCreate(transaction) (false for share-sheet transactions) into cleanupAndNavigateAfterExpenseCreate (SubmitDetailsPage.tsx:530), so navigateAfterExpenseCreate.ts:91-93 calls dismissModalAndOpenReportInInboxTab. Furthermore, on narrow layouts (iOS), navigateAfterExpenseCreate.ts:141 passes forceReplace: !(isLookingAroundUser && isSelfDMDestination) — which keeps non-LOOKING_AROUND callers locked on their current tab (Inbox) instead of switching to Search.

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

Update SubmitDetailsPage so successful share-sheet expense submission consistently lands on Spend > Expenses (ROUTES.SEARCH_ROOT with buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE}) and getSearchKeyForDataType(CONST.SEARCH.DATA_TYPES.EXPENSE)), while leaving ShareDetailsPage (normal chat/attachment sharing) unchanged:

  1. Drive usePreMountDestination directly with the Spend > Expenses route:
    • Compute expensesSearchRoute via ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE}), searchKey: getSearchKeyForDataType(CONST.SEARCH.DATA_TYPES.EXPENSE)}).
    • Check if the user is already on the Expenses Search root (!Navigation.getIsFullscreenPreInsertedUnderRHP() && isSearchTopmostFullScreenRoute() && getCurrentSearchQueryJSON()?.type === CONST.SEARCH.DATA_TYPES.EXPENSE). Pass undefined when already there so we never pre-insert a duplicate Search screen underneath the modal; otherwise pass expensesSearchRoute whenever !!transaction is ready.
  2. Unify post-submit exit through revealPreMountDestination and remove unnecessary report-arrival waits:
    • Because Spend > Expenses does not depend on the optimistic destination report existing in COLLECTION.REPORT, remove isDestinationReportMissing, pendingNavigationReportID, revealPendingNavigation, and the topmostReportId !== postSubmitNavigationReportID report-reveal branch.
    • In finishRequestAndNavigate, call performExpenseCreate(), set hasCalledReveal.current = true, and invoke revealPreMountDestination(() => { cleanupAndNavigateAfterExpenseCreate({...cleanupParams, shouldNavigate: false}); setIsConfirming(false); }).
    • On narrow iOS and wide layouts alike, usePreMountDestination's reveal() cleanly dismisses the modal when already on Expenses (route === undefined), reveals the pre-inserted Expenses screen on the fast path, or calls Navigation.revealRouteBeforeDismissingModal(expensesSearchRoute, {afterTransition}) if the user tapped Confirm immediately — switching away from Inbox without triggering navigateAfterExpenseCreate's Inbox guard or narrow forceReplace: true tab lock.
  3. Update automated tests (tests/ui/SubmitDetailsPageTest.tsx):
    • Update post-submit assertions to verify pre-mount and reveal target ROUTES.SEARCH_ROOT (Spend > Expenses) for both workspace and self-DM expenses, even when COLLECTION.REPORT lacks the destination report and Inbox is topmost.
    • Add tests verifying: (a) submitting when already on Spend > Expenses skips pre-insert and calls dismissModal, (b) immediate confirm before idle pre-insert calls revealRouteBeforeDismissingModal(expensesSearchRoute), and (c) Back/Cancel calls cleanupPreMount().

What alternative solutions did you explore? (Optional)

  • Extending navigateAfterExpenseCreate with an isShareFlow flag scoped only to isSelfDMDestination: Rejected for two reasons: (1) workspace/report expenses submitted via the iOS Share Sheet still land in Inbox instead of Spend > Expenses as reported, and (2) navigateAfterExpenseCreate.ts:141 still passes forceReplace: true on narrow iOS unless also updated, which prevents switching off the Inbox tab.
  • Passing isFromGlobalCreate: true and canPreInsertSearch: true to getSubmitExpensePreMountDestinationRoute: Rejected because getSubmitExpensePreMountDestinationRoute.ts:65 still disables Search pre-insertion whenever isReportTopmostSplitNavigator() is true.

How this differs from MelvinBot's proposal: MelvinBot suggests reusing navigateAfterExpenseCreate.ts:105-140, which still hits the isReportTopmostSplitNavigator() Inbox early-return (line 86) and narrow forceReplace: true tab lock (line 141). Routing through usePreMountDestination directly with the canonical expensesSearchRoute (and guarding isAlreadyOnExpensesSearch) solves both workspace and self-DM share submissions across narrow iOS and wide layouts, avoids redundant Search pre-insertion, and removes the unnecessary report-arrival timeout machinery.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~015730018077950625

ZeroNeroIV avatar Nov 26 '26 07:11 ZeroNeroIV

📣 @ZeroNeroIV! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 26 '26 07:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~015730018077950625

ZeroNeroIV avatar Nov 26 '26 07:11 ZeroNeroIV

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 26 '26 07:11 melvin-bot[bot]

@sobitneupane Huh... This is 4 days overdue. Who can take care of this?

@MelvinBot Could you please provide more details on the implementation?

sobitneupane avatar Dec 01 '26 11:12 sobitneupane

Yes—the implementation can stay local to the share-sheet expense confirmation page. Both personal and workspace expenses should land on Spend > Expenses, while ordinary attachment/message sharing remains unchanged.

1. Set Expenses as the destination

Replace the report-based destination in SubmitDetailsPage.tsx:325–350 with the canonical Expenses route:

const expensesRoute = ROUTES.SEARCH_ROOT.getRoute({
    query: buildCannedSearchQuery({
        type: CONST.SEARCH.DATA_TYPES.EXPENSE,
    }),
    searchKey: getSearchKeyForDataType(CONST.SEARCH.DATA_TYPES.EXPENSE),
});

Pass that route directly to usePreMountDestination, rather than changing the shared expense-destination helper or introducing an isShareFlow flag.

If the underlying screen is already the unfiltered Expenses root, pass undefined instead: the hook can simply dismiss the modal. Checking only query.type === expense is insufficient—a workspace, merchant, or date filter could hide the new expense.

Keep this destination decision stable during the flow; pre-inserting Search must not cause a subsequent render to mistake that inserted screen for the original destination.

2. Use one successful-completion path

Replace the report-specific completion branches in SubmitDetailsPage.tsx:538–581 with this sequence:

cancelTracking();
performExpenseCreate();
hasCalledReveal.current = true;

revealPreMountDestination(() => {
    cleanupAndNavigateAfterExpenseCreate({
        ...cleanupParams,
        shouldNavigate: false,
    });
    setIsConfirming(false);
});

The important distinction is:

  • revealPreMountDestination owns navigation to Expenses.
  • cleanupAndNavigateAfterExpenseCreate still performs cleanup and bookkeeping, but must not navigate back to Inbox.
  • Keep the actual expense report IDs in cleanupParams; they still identify the created expense’s destination report.

The hook already handles narrow/wide layouts and immediate confirmation before pre-mount finishes, including a fallback reveal when necessary: usePreMountDestination/index.ts:71–106.

3. Remove only report-dependent navigation waits

Remove the pending-report subscription, report-arrival effect/timeouts, and explicit report-reveal fallbacks in SubmitDetailsPage.tsx:352–398. Expenses navigation no longer needs to wait for the destination chat report to appear.

Preserve receipt conversion/storage, GPS handling, duplicate-submit protection, expense creation, and telemetry. Keep cleanupPreMount() on Back/Cancel so abandoning the flow restores the original navigation state.

4. Update regression coverage

Update SubmitDetailsPageTest.tsx:478–639 to verify:

  • Personal and workspace submissions both reveal canonical Expenses.
  • Missing destination reports do not delay navigation.
  • Immediate confirmation works before pre-mount completes.
  • Already on canonical Expenses → dismiss only.
  • Filtered Expenses → reveal canonical, unfiltered Expenses.
  • Cleanup runs once after the transition with shouldNavigate: false.
  • Back/Cancel removes the pre-mounted destination.
  • Narrow and wide layouts behave consistently.

Clarification to my earlier proposal: reuse the canonical Search route construction, not the shared navigation helper’s routing decisions. Those decisions intentionally retain Inbox behavior for other expense flows and need not change here.

This is a code-verified implementation plan; no changes or runtime tests were performed. Native iOS verification remains necessary for the system share-sheet entry path.


view run

MelvinBot avatar Dec 01 '26 11:12 MelvinBot