Skip to content

Fix: prevent dynamic route crash when "action" query param exists in both base path and suffix - #98949

Draft
MelvinBot wants to merge 1 commit into
mainfrom
claude-fixDynamicRouteDuplicateActionCrash
Draft

Fix: prevent dynamic route crash when "action" query param exists in both base path and suffix#98949
MelvinBot wants to merge 1 commit into
mainfrom
claude-fixDynamicRouteDuplicateActionCrash

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

createDynamicRoute builds a route by concatenating the current active route (base) with a dynamic suffix and merging their query strings via mergeQueryStrings. When the same query key appeared in both, mergeQueryStrings threw a fatal error instead of navigating.

On the money-request Tag step this collision is reachable through normal use: the tag row's onPress calls createDynamicRoute with no explicit basePath, so it falls back to Navigation.getActiveRoute() (which keeps the current ?action=… query string), while the expense-tag suffix always carries its own action param. When the active route already carries ?action=…, both base and suffix contain action, the guard throws, and — because the throw fires inside an onPress handler on iOS Hermes — it crashes the app (Sentry APP-JSV / APP-JPQ, level: fatal).

The guard was treating a normal, recoverable navigation as an unrecoverable invariant violation. This change makes mergeQueryStrings non-fatal: when a key exists in both, the suffix value wins (it is the intended destination of the tap — params.set already does this) and a differing value is logged via Log.warn for visibility instead of throwing. This mirrors the recoverable-navigation approach already used for the same util in #97849.

Added/updated unit tests in tests/navigation/createDynamicRouteTests.ts to cover the collision case (suffix wins + warn logged) and the same-value case (no warn).

Fixed Issues

$ #98792
PROPOSAL: #98792 (comment)

Tests

  1. Open an expense from Search (/search/view/:reportID/expense-report) and enter a money-request flow that lands on the Tag step on a route already carrying an ?action=… query param.
  2. Tap a tag row.
  3. Verify the app navigates to the tag selection step instead of crashing.
  4. Verify that no errors appear in the JS console.
  • 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]."

  • 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 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 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…param

Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team August 19, 2026 07:03
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Aug 19, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-fixDynamicRouteDuplicateActionCrash
git checkout -b claude-fixDynamicRouteDuplicateActionCrash upstream/claude-fixDynamicRouteDuplicateActionCrash
git push -u origin claude-fixDynamicRouteDuplicateActionCrash

Then you can close this PR and open a new one from your fork.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

✅ Android test passed

Ran the PR's testing steps on standalone Android NewDot (branch claude-fixDynamicRouteDuplicateActionCrash, fix commit 0d404d6). Tapping the Tag row on a route already carrying an ?action=… query param navigated cleanly to the Tag selection step instead of crashing — confirming the fix.

Steps performed

  1. Signed in, created a workspace, enabled the Tags feature and added a "Marketing" tag.
  2. Created a manual expense and reached the Tag step normally during the money-request flow.
  3. Opened the expense's detail view (MoneyRequestView — a route that carries ?action=…) and tapped the Tag row, whose onPress calls createDynamicRoute with no explicit basePath → the exact duplicate-action collision the PR targets.
  4. App navigated to the Tag selection screen with "Marketing" checked — no crash, no ANR, no error dialog. App process stayed alive and responsive backing out through the full nav stack.
Check Result
Money-request flow reaches Tag step normally ✅ Pass
Tapping tag row on a route with ?action=… navigates instead of crashing ✅ Pass
App remains responsive / no crash after navigation ✅ Pass
No JS console errors observed ✅ Pass

Screenshots and recording attached below.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Web test could not be completed — session lost

I was unable to run the PR's testing steps on Web this run. The browser session was lost to an off-app navigation to help.expensify.com (a forbidden zone that drops the session unrecoverably), and the web tooling has no supported way to reopen/reload it — CI owns the session lifecycle. I retried with a fresh attempt, but the session was already off-app on the ExpensifyHelp page before any step could run, so none of the Tag-step verification steps were reached. This is an environment/session issue, not a defect in the PR.

What tripped it up: while navigating Workspace settings toward More features → Tags, a "Learn more"/plan-type link performed a full-window navigation to the help site. That workaround was only needed because the workspace-settings left sidebar wasn't reliably reachable via the accessibility snapshot on this build.

For reference, the same fix already passed on Android — tapping the Tag row on an existing expense's detail view (a route carrying ?action=…) navigated cleanly to the Tag selection step with no crash. See the Android results above.

Please re-run the Web test (Melvin-Test-Web label / re-trigger) to get web coverage, or complete the web testing steps manually.

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants