Skip to content

Fix distance waypoint "Not here" after Scan receipt then Track distan…#94772

Merged
marcochavezf merged 6 commits into
Expensify:mainfrom
oqildev:fix/88183-distance-waypoint-not-here
Jul 16, 2026
Merged

Fix distance waypoint "Not here" after Scan receipt then Track distan…#94772
marcochavezf merged 6 commits into
Expensify:mainfrom
oqildev:fix/88183-distance-waypoint-not-here

Conversation

@oqildev

@oqildev oqildev commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Launcher quick-action deeplinks (the home-screen "Scan receipt" / "Track distance" shortcuts) enter NewDot through IOURequestRedirectToStartPage, which navigates straight to the per-request route without going through startMoneyRequest. A previous shortcut's draft therefore survived under OPTIMISTIC_TRANSACTION_ID; a leftover "scan" draft has no comment.waypoints, so the distance start page showed placeholder Start/Stop waypoints (rendered locally) while the waypoint editor read the empty waypoints from Onyx and rendered the "Not here" page.

This clears the stale draft in the redirect (mirroring startMoneyRequest) so the destination start page rebuilds a fresh draft with the correct shape, including the distance start/stop waypoints. The OPTIMISTIC_TRANSACTION_ID fallback covers the cold-start case where the draft collection has not hydrated yet. A regression test that fails without the fix is added.

Fixed Issues

$ #88183
PROPOSAL: #88183 (comment)

Tests

  1. Long-press the app icon on the home screen and tap Scan receipt.
  2. Fully background/close the app without saving anything.
  3. Long-press the app icon again and tap Track distance.
  4. On the Track distance screen, tap the Start (or Stop) waypoint.
  5. Verify the waypoint address editor opens (NOT the "Hmm... it's not here" page).

mWeb/Web (no home-screen shortcut): open /start/create/scan, hard-refresh the page, then open /start/create/distance-map, and tap the Start (or Stop) waypoint. Verify the editor opens.

  • Verify that no errors appear in the JS console

Offline tests

Same steps as in Tests. clearMoneyRequest is a synchronous Onyx multiSet with no network involvement, so the fix behaves identically while offline (the waypoint editor opens instead of the "Not here" page).

QA Steps

Same as Tests above.

mWeb/Web: open /start/create/scan, hard-refresh the page, then open /start/create/distance-map, and tap the Start (or Stop) waypoint. Verify the editor opens.

  • 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
  • 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 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 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)
  • 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)
  • 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.
  • 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
distance-scan-fix.mov
Android: mWeb Chrome
android.-.mweb.mp4
iOS: Native
ios-distance-.mp4
iOS: mWeb Safari
ios.-.mweb.MOV
MacOS: Chrome / Safari
web.-.distance.mp4

…ce shortcut

Launcher quick-action deeplinks (the home-screen "Scan receipt" / "Track
distance" shortcuts) enter NewDot through IOURequestRedirectToStartPage, which
navigates straight to the per-request route without going through
startMoneyRequest. A previous shortcut's draft therefore survived under
OPTIMISTIC_TRANSACTION_ID; a leftover "scan" draft has no comment.waypoints, so
the distance start page showed placeholder Start/Stop waypoints (rendered
locally) while the waypoint editor read the empty waypoints from Onyx and
rendered the "Not here" page.

Clear the stale draft in the redirect (mirroring startMoneyRequest) so the
destination start page rebuilds a fresh draft with the correct shape, including
the distance start/stop waypoints. The OPTIMISTIC_TRANSACTION_ID fallback covers
the cold-start case where the draft collection has not hydrated yet.

Add a regression test that fails without the fix.

Expensify#88183
@oqildev
oqildev requested review from a team as code owners June 27, 2026 10:55
@melvin-bot
melvin-bot Bot requested review from ChavdaSachin and trjExpensify and removed request for a team June 27, 2026 10:55
@melvin-bot

melvin-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

@ChavdaSachin 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: 7f62f38b10

ℹ️ 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/IOURequestRedirectToStartPage.tsx Outdated
Comment thread src/pages/iou/request/IOURequestRedirectToStartPage.tsx Outdated
…e-init

- codex P1: `validTransactionDraftIDsSelector` returns `[]` (not `undefined`) before
  the draft collection hydrates, so the clear must always include
  OPTIMISTIC_TRANSACTION_ID. A `?? [...]` fallback alone passed an empty list on a
  cold start / hard-refresh and removed nothing, letting the stale scan draft survive.
- PERF-16: guard the empty-dependency effect with a per-mount `useRef` so the
  non-idempotent `clearMoneyRequest` + redirect run exactly once under Strict Mode's
  dev double-invoke. A module-level flag would be wrong here — this page remounts on
  every quick-action deeplink, so a flag that never resets would block every shortcut
  after the first.
- Add a regression test for the empty-selector (cold-start) case.
@oqildev
oqildev force-pushed the fix/88183-distance-waypoint-not-here branch from 2c4decc to a1018ef Compare June 27, 2026 11:39
trjExpensify
trjExpensify previously approved these changes Jun 29, 2026

@trjExpensify trjExpensify 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.

Nice find. 👍

Resolve import-block conflict in IOURequestRedirectToStartPage.tsx: keep the
stale-draft clear (clearMoneyRequest + useOnyx selector + per-mount useRef
guard) on top of main's updated request-type routing and new import grouping.
@oqildev

oqildev commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Hey @ChavdaSachin, this one had drifted a bit behind main while it was waiting, so I went ahead and merged the latest main in and fixed the conflict.

It was only in IOURequestRedirectToStartPage.tsxmain had added a few new request types and regrouped the imports in that file, so I just re-applied the stale-draft clear on top of that. Nothing else in the fix changed, and the diff is back down to only the fix + the regression test.

Should be ready for another look whenever you get a chance 🙏

oqildev added 2 commits July 8, 2026 10:06
The test file predated main's codebase-wide oxfmt pass; reformat its import
block to match the current oxfmt 0.55.0 grouping so the fmt CI check passes.
Main refactored IOURequestRedirectToStartPage to route through
startDistanceRequest/startMoneyRequest and added its own didRedirectRef guard.
Those helpers only clear the draft IDs passed to them and the redirect invokes
them with undefined (and the DISTANCE_ODOMETER branch navigates directly), so
the stale OPTIMISTIC_TRANSACTION_ID draft still survives. Re-applied the
stale-draft clear on top of the refactor (dropping our now-redundant ref guard
in favor of main's didRedirectRef).
@ChavdaSachin

ChavdaSachin commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • 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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-07-13.at.5.54.28.AM.mov
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-07-13.at.5.54.28.AM.mov
iOS: mWeb Safari
MacOS: Chrome / Safari

@ChavdaSachin ChavdaSachin 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! ✅

@melvin-bot
melvin-bot Bot requested a review from marcochavezf July 13, 2026 00:30

@marcochavezf marcochavezf 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.

Thanks for the changes! Just a few requested changes in the code comments

Comment on lines +38 to +46
// This page is the entry point for launcher quick-action deeplinks (e.g. the home-screen "Scan receipt" /
// "Track distance" shortcuts). A previous shortcut's draft survives under OPTIMISTIC_TRANSACTION_ID: a
// leftover "scan" draft has no `comment.waypoints`, and the distance start page only shows placeholder
// waypoints locally without writing them back, so tapping a waypoint opens the "Not here" page. The
// start*Request helpers below only clear the draft IDs they are handed and we invoke them with `undefined`,
// and the DISTANCE_ODOMETER branch navigates directly without them, so clear the stale draft here to cover
// every branch. OPTIMISTIC_TRANSACTION_ID is always included so the leftover draft is removed even before
// the draft collection hydrates — the selector returns `[]` (not `undefined`) while loading, so a `?? [...]`
// fallback alone would pass an empty list and clear nothing (#88183).

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.

Could we make this comment a bit more concise and remove the reference to #88183? It feels a little too verbose and reads a bit AI-generated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done - trimmed it down and dropped the issue reference.

});
});

// Regression test for https://github.com/Expensify/App/issues/88183

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.

Also here, instead of referencing the direct regression, can we just state what this test is covering and why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done - reworded it to say what the test covers and why instead of linking the issue.

expect(Navigation.navigate).toHaveBeenCalledTimes(1);
});

// PR review (codex P1): on a cold start / hard-refresh the draft collection may not be hydrated when this

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.

Also here, just stating what we're covering in the codebase and why

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done - same here, described what it's covering and why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Per reviewer feedback, make the clear-draft comment and the two test
descriptions concise and state what/why they cover instead of linking the
issue or the codex review.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...ages/iou/request/IOURequestRedirectToStartPage.tsx 85.71% <100.00%> (+85.71%) ⬆️
... and 372 files with indirect coverage changes

@oqildev

oqildev commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @marcochavezf

Can you check last changes?
Thank you.

@marcochavezf
marcochavezf merged commit 3e254e2 into Expensify:main Jul 16, 2026
39 of 40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/marcochavezf in version: 9.4.36-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no changes required

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

Why: This is an internal bug fix, not a behavior or feature change. The PR clears a stale draft transaction (OPTIMISTIC_TRANSACTION_ID) inside the quick-action redirect (IOURequestRedirectToStartPage.tsx) so that after using Scan receipt then Track distance from the home-screen shortcut, the waypoint editor opens correctly instead of showing the "Hmm... it's not here" page.

The fix simply restores the already-expected behavior for Track distance / distance waypoints — it introduces no new UI, settings, labels, tabs, or user-facing workflows. The existing articles that touch distance expenses and waypoints (e.g. Distance-Expenses.md, Create-an-Expense.md) already describe the correct behavior and remain accurate after this change.

Since no help-site content is affected, I did not open a draft docs PR.

Note: browser-based verification of the live UI was unavailable in this run, so feature/label names were confirmed from the code and existing help articles rather than the running app.

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