Skip to content

refactor: Remove shouldHandleNavigation from createDistanceRequest#93545

Merged
Valforte merged 11 commits into
Expensify:mainfrom
TaduJR:refactor-code-to-keep-navigation-handling-in-the-UI-components
Jul 6, 2026
Merged

refactor: Remove shouldHandleNavigation from createDistanceRequest#93545
Valforte merged 11 commits into
Expensify:mainfrom
TaduJR:refactor-code-to-keep-navigation-handling-in-the-UI-components

Conversation

@TaduJR

@TaduJR TaduJR commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Part of #84631 (PR 5). The issue's goal: action files should only do API + Onyx writes — navigation belongs in the view layer.

This PR makes createDistanceRequest navigation-free, the same treatment PR 3+4 gave requestMoney/trackExpense:

  • Dropped the nav/flow-control params (shouldHandleNavigation, shouldDeferForSearch, backToReport) and moved navigation to the UI — the confirmation flow now goes through the shared performPostBatchCleanup, and skip-confirm already handled its own nav. The action keeps highlightTransactionOnSearchRouteIfNeeded, which is a pure-Onyx side effect, not navigation.
  • The action returns the ids it created{iouReport, chatReportID, transactionID} — so the UI can navigate to and highlight the new report/expense. The action mints these internally and the draft id is cleared after submit, so the UI can't derive them itself (same pattern as requestMoney's {iouReport}).
  • Removed the Duplicate.ts shouldHandleNavigation: false workaround now that the param is gone.

While here, I also fixed a highlight bug in the shared cleanup helper (cleanupAndNavigateAfterExpenseCreate): it suppressed the new-expense highlight whenever a backToReport was set — even when that report is the chat you return to (the "Add expense from a report preview" flow). It now decides based on whether the destination is a chat, which is the real condition.

Fixed Issues

$ #84631
PROPOSAL: #84631 (comment)

Tests

1. Create a distance expense via the review screen

  1. Open a 1:1 chat → compose +Track distance.
  2. Map tab: enter a start and a stop address → Next → review → Create expense.
  3. Verify: the window closes, you return to that chat, and the new distance expense is visible with the right amount/merchant.
  4. Repeat on the Manual tab (type a distance) and the Odometer tab (start/end readings).
  5. Verify: each lands back on the correct chat with the expense visible

2. One-tap create

  1. Create one distance expense in a 1:1/DM chat first (sets it as your last action).
  2. Tap the green + → tap the quick-action for that same chat.
  3. Verify: the expense is created without a review screen; you land on the chat, expense visible.
  4. Repeat the quick action targeting a workspace chat → verify it does show the review screen

3. Global create → Reports list highlight

  1. Go to the Reports (Search/Spend) tab → green +Track distance → pick participant(s)/workspace → Create expense.
  2. Verify: you land on the Reports Expenses list and the new row is briefly highlighted and scrolled into view.
  3. Repeat using the Map and Odometer tabs.

4. "Add expense" from a report preview → highlight in the chat

  1. Create Empty Report
  2. Tap Add expense on the card → Track distance → create the expense.
  3. Verify: you return to that chat and the new expense is briefly highlighted in the preview card.
  4. Repeat, but this time add a regular (manual) expense instead of distance.
  5. Verify: the manual expense is now also highlighted in the preview card.

5. Split distance

  1. Group chat → +Split expenseDistance → enter a distance → select 2+ people → Split.
  2. Verify: you land on the split/group chat with the split expense visible.
  3. Repeat with people who don't already share a group chat → verify a new group is created and you land in it (never an empty/missing chat).

6. Track distance destination

  1. From a workspace chat: compose +Track distance → create.
  2. Verify: you land on that workspace chat (not your personal/self chat), expense visible.
  3. From the global + (not on a workspace) → Track distance → verify it lands on your self chat (unreported) with the expense.

7. GPS distance

  1. Phone: +Track distanceGPS tab → Start → move/wait → Stop → Save → Create expense.
  2. Verify: expense created with the tracked distance, window closes, you land on the chat.
  3. Background the app mid-recording and return before saving → verify the trip isn't lost and the expense still creates.

8. Duplicate distance

  1. Open an existing distance expense → Duplicate → verify a copy is created.
  2. In Reports, multi-select distance expenses → bulk Duplicate → verify copies are created.
  3. Try to duplicate a report that contains a distance expense into a different workspace → verify the distance line is skipped (expected — mileage rates don't transfer across workspaces).

9. Skip-confirm dismiss/reveal across surfaces

  1. Run one-tap distance from Inbox, from the Search/Reports/Spend tab, and from inside a right-hand panel.
  2. Verify: the window dismisses/reveals first, the expense lands in the right report, and there's no double-navigation.

10. Offline

  1. Go offline → repeat Test 1 and Test 2.
  2. Verify: the expense appears immediately in a pending (greyed) style and navigation behaves the same; back online it finishes with no error and no duplicate.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android-Native.mp4
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Mac-Chrome.mp4

@TaduJR TaduJR requested review from a team as code owners June 14, 2026 13:35
@melvin-bot melvin-bot Bot requested review from linhvovan29546 and trjExpensify and removed request for a team June 14, 2026 13:35
@melvin-bot

melvin-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

@linhvovan29546 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc624a9a44

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/iou/request/step/confirmation/useExpenseSubmission.ts
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
...on/helpers/cleanupAndNavigateAfterExpenseCreate.ts 100.00% <100.00%> (ø)
src/libs/actions/IOU/Duplicate.ts 91.76% <ø> (ø)
src/libs/actions/IOU/Split.ts 72.24% <100.00%> (-0.49%) ⬇️
...stance/handleMoneyRequestStepDistanceNavigation.ts 83.67% <100.00%> (-0.17%) ⬇️
.../request/step/confirmation/useExpenseSubmission.ts 69.08% <87.50%> (+0.33%) ⬆️
... and 15 files with indirect coverage changes

@TaduJR

TaduJR commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d16314115

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/iou/request/step/confirmation/useExpenseSubmission.ts
@TaduJR TaduJR marked this pull request as draft June 14, 2026 16:32
@TaduJR

TaduJR commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 66d3a95e83

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

2 similar comments
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 66d3a95e83

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 66d3a95e83

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 66d3a95e83

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@TaduJR TaduJR marked this pull request as ready for review June 15, 2026 06:19
@trjExpensify trjExpensify removed their request for review June 15, 2026 11:05
@trjExpensify

Copy link
Copy Markdown
Contributor

PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself.

…de-to-keep-navigation-handling-in-the-UI-components

# Conflicts:
#	src/libs/actions/IOU/Split.ts
@TaduJR

TaduJR commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: e9940c8bee

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/actions/IOU/Split.ts
Comment thread src/libs/actions/IOU/Split.ts
…de-to-keep-navigation-handling-in-the-UI-components
@TaduJR

TaduJR commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @linhvovan29546

How is this one going?

@linhvovan29546

Copy link
Copy Markdown
Contributor

@TaduJR Could you please merge main again?

@TaduJR

TaduJR commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@TaduJR Could you please merge main again?

Sure, but I just discovered main workflows are failing. Lets wait a little til they are resolved.

…de-to-keep-navigation-handling-in-the-UI-components

# Conflicts:
#	src/libs/actions/IOU/Split.ts
@TaduJR

This comment was marked as resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 674b281178

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/actions/IOU/Split.ts Outdated
@TaduJR

TaduJR commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a41b73870

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@TaduJR

TaduJR commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 1a41b73870

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@TaduJR

TaduJR commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@TaduJR Could you please merge main again?

Done @linhvovan29546

Thanks!

@linhvovan29546

Copy link
Copy Markdown
Contributor

Reviewing...

@melvin-bot melvin-bot Bot requested a review from Valforte July 6, 2026 09:15

@Valforte Valforte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Valforte Valforte merged commit 2a89475 into Expensify:main Jul 6, 2026
35 of 38 checks passed
@OSBotify

OSBotify commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🚧 Valforte has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Valforte in version: 9.4.29-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

This PR is a purely internal code refactor with no user-facing behavior changes, so nothing under docs/articles needs updating. I did not create a draft docs PR.

Why no docs update is needed

The PR makes createDistanceRequest navigation-free — it moves navigation out of the action file and into the UI layer (the same architectural cleanup done for requestMoney/trackExpense in earlier PRs of #84631). All changes are in src/libs/ action/navigation helpers, src/pages/iou/... view code, and tests:

  • src/libs/actions/IOU/Split.ts, Duplicate.ts, cleanupAndNavigateAfterExpenseCreate.ts — internal params/plumbing
  • src/pages/iou/request/step/.../useExpenseSubmission.ts, handleMoneyRequestStepDistanceNavigation.ts — view-layer nav
  • tests/... — test updates

The end-user workflows documented on the help site are unchanged:

The only behavior change is a small in-app highlight fix (the newly created expense now highlights correctly in the "Add expense from a report preview" flow). That's a transient visual detail not described in any help article, so no documentation covers it.

@TaduJR — since no docs changes are needed, there's no linked help site PR to review. If you believe a user-facing behavior here should be documented, let me know and I'll draft one.

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Valforte in version: 9.4.31-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

I reviewed the changes in this PR against the help site articles under App/docs/articles and found no documentation updates are needed.

Why: This is an internal code refactoring — it moves navigation handling out of the createDistanceRequest action file and into the view layer (the stated goal of #84631: action files should only do API + Onyx writes). All user-facing behavior is preserved:

  • Dropped nav/flow-control params (shouldHandleNavigation, shouldDeferForSearch, backToReport) and relocated navigation to the UI via the shared performPostBatchCleanup — the what the user sees is unchanged.
  • The action now returns the ids it created so the UI can navigate/highlight — same outcome, different code owner.
  • The one functional change is a highlight bug fix (a newly created expense now correctly highlights in the preview card when returning to that chat) — this is a minor visual behavior, not something described in any help article.

The help site documents how to create distance expenses, split expenses, duplicate expenses, etc. — none of those documented flows or their steps change here, which the PR's own QA steps ("Same as tests," verifying identical behavior) confirm.

Since no changes are required, I did not create a draft docs PR.


@TaduJR, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.31-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants