Skip to content

83851 - migrate money request report, edit report and tag steps to dynamic route - #97460

Merged
mjasikowski merged 7 commits into
Expensify:mainfrom
suneox:83851-migrate-money-request-part-1-suneox
Aug 4, 2026
Merged

mjasikowski merged 7 commits into
Expensify:mainfrom
suneox:83851-migrate-money-request-part-1-suneox

Conversation

@suneox

@suneox suneox commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Migrates the money-request report, edit-report and tag steps to dynamic URL navigation (feature #73825), removing backTo/forwardTo. Three legacy static routes become dynamic routes with suffixes expense-report, expense-report-edit and expense-tag; the old path params (action, iouType, transactionID, reportID, orderWeight) move into query params of the suffix, mirroring the MONEY_REQUEST_STEP_TAX_RATE pattern already on main. Each route declares entryScreens (Confirmation + report views) and an OldRoutes backward-compat matcher so legacy deep links redirect to the new URL. Back uses useDynamicBackPath, so the suffix + its query are stripped cleanly on return.

Fixed Issues

$ #83851
PROPOSAL:

Tests

DYNAMIC_ROUTES.MONEY_REQUEST_STEP_REPORT — pick a report for an expense (expense-report)

Case 1.1 — Confirmation page → Report field

Target: src/components/MoneyRequestConfirmationList/sections/ReportField.tsx#L134

Precondition: you are on the Confirmation step of a new expense, on a workspace with ≥2 outstanding reports (with a single report the Report field is not interactive).

Steps:

  1. Open the app and sign in with the test account.
  2. Tap FAB (+) → Create expense → enter an amount → Next → pick a workspace chat → land on Confirmation.
  3. Note the current URL (the base), e.g. /create/submit/confirmation/<transactionID>/<reportID>.
  4. Tap the Report field.
  5. Expected: the report picker opens and the URL is <base>/expense-report?action=create&iouType=submit&transactionID=<txn>&reportID=<report> — no ?backTo=.
  6. Pick a different report.
  7. Expected: you are back on Confirmation and the Report field shows the report you picked.

Case 1.2 — Expense details (MoneyRequestView) → Report field

Target: src/components/ReportActionItem/MoneyRequestView.tsx#L1602

Precondition: a submitted, not-yet-settled expense you can edit (canEditReport === true).

Steps:

  1. Open the app and sign in.
  2. Open an expense report → tap an expense to open its transaction thread (URL /r/<id>).
  3. Tap the Report row in the expense details.
  4. Expected: URL is /r/<id>/expense-report?action=edit&iouType=submit&transactionID=<txn>&reportID=<id> and the report picker opens in the RHP.
  5. Tap Back.
  6. Expected: you return to /r/<id> with the transaction thread intact (no reload, scroll preserved).

Case 1.3 — After workspace upgrade → report step reopens

Target: src/pages/iou/request/step/IOURequestStepUpgrade.tsx#L224

Precondition: the expense lives on a workspace that does not have the Reports feature yet, so tapping the Report field goes through the Upgrade screen.

Steps:

  1. Open such an expense → tap the Report field.
  2. Expected: the Upgrade screen opens.
  3. Complete the upgrade (Upgrade → Got it).
  4. Expected: the Upgrade RHP closes and the report picker opens at /r/<reportID>/expense-report?action=edit&iouType=submit&transactionID=<txn>&reportID=<reportID>.
  5. ⚠️ Verify the URL does not contain an upgrade segment — the suffix is explicitly anchored to /r/<reportID> because getActiveRoute() would still resolve to the upgrade screen being popped.
  6. Tap Back → Expected: you return to /r/<reportID>.

Case 1.4 — Picking a report in the global create flow

Target: src/pages/iou/request/step/IOURequestStepReport/hooks/useReportSelectionActions.ts#L181

Precondition: the expense was started from the global FAB (+) (so transaction.isFromGlobalCreate === true) with action === create.

Steps:

  1. From Inbox, tap FAB (+) → Create expense → amount → Next → pick a workspace chat → Confirmation.
  2. Tap the Report field → the report picker opens (expense-report suffix).
  3. Pick a report that belongs to a different workspace.
  4. Expected: you land back on the Confirmation step of the new workspace, with exactly one Confirmation screen on the stack (no duplicated Confirmation).
  5. Tap Back from Confirmation → Expected: the wizard exits normally, you do not land on a stale Confirmation screen.

Case 1.5 — Refresh / deep link restores the stack

Steps:

  1. Follow case 1.2 up to step 4 (URL /r/<id>/expense-report?...).
  2. Copy the URL and press F5.
  3. Expected: the report picker reopens in the RHP with the transaction thread /r/<id> underneath (not Home, not /not-found).
  4. Tap Back → Expected: you land on /r/<id>.
  5. Open the same URL in a new tab (cold deep link) and repeat steps 3–4.

Case 1.6 — Legacy URL redirect

Target: src/libs/Navigation/linkingConfig/OldRoutes.ts — '/*/*/report/*/*'

Steps:

  1. Paste the legacy URL https://dev.new.expensify.com:8082/edit/submit/report/<transactionID>/<reportID> and hit Enter.
  2. Expected: it redirects to /r/<reportID>/expense-report?action=edit&iouType=submit&transactionID=<transactionID>&reportID=<reportID> and opens the report picker.
  3. ⚠️ A legacy URL that still carries ?backTo=… loses its query (the trailing wildcard of the matcher swallows it) — same known trade-off as the taxRate redirect already on main. Not a failure.


DYNAMIC_ROUTES.MONEY_REQUEST_EDIT_REPORT — move expenses to another report (expense-report-edit)

Case 2.1 — Expense header → Move expense

Target: src/components/MoneyRequestHeaderSecondaryActions.tsx#L570

Precondition: an unsettled expense on a paid workspace, so the ⋯ (More) menu offers Move expense.

Steps:

  1. Open the app and sign in → open an expense (transaction thread /r/<id>).
  2. Tap ⋯ (More) in the header → tap Move expense.
  3. Expected: URL is /r/<id>/expense-report-edit?action=edit&iouType=submit&reportID=<parentReportID>&shouldTurnOffSelectionMode=true&transactionID=<txn> and the report list opens in the RHP.
  4. Pick another report.
  5. Expected: the expense is moved and the RHP is dismissed back to the report view.

Case 2.2 — Bulk Move expenses from the selection toolbar

Target: src/hooks/useSelectedTransactionsActions.ts#L502

Precondition: an expense report with ≥2 expenses, selection mode enabled.

Steps:

  1. Open an expense report with ≥2 expenses.
  2. Enable selection mode and select 2 expenses.
  3. Open the actions dropdown → Move expenses.
  4. Expected: URL is <report base>/expense-report-edit?action=edit&iouType=submit&reportID=<reportID> — no transactionID query (bulk selection comes from context).
  5. Pick a destination report → Expected: both expenses move, and selection mode is turned off according to shouldTurnOffSelectionMode.

Case 2.3 — Report header (⋯) → Move expense (single)

Target: src/hooks/useExpenseActions.ts#L475

Precondition: an expense report containing exactly one non-pending-delete expense.

Steps:

  1. Open an expense report with a single expense.
  2. Tap ⋯ (More) in the report header → Move expense.
  3. Expected: URL is <base>/expense-report-edit?action=edit&iouType=submit&reportID=<moneyRequestReportID>&shouldTurnOffSelectionMode=true&transactionID=<txn>.
  4. Pick a destination report → Expected: the expense is moved and the RHP closes.

Case 2.4 — Back from the report picker (nothing selected)

Target: src/pages/iou/request/step/IOURequestEditReportCommon.tsx#L194 (receives useDynamicBackPath('expense-report-edit'))

Steps:

  1. Follow case 2.1 up to step 3.
  2. Tap Back.
  3. Expected: the URL returns to the exact base (/r/<id>) — the suffix and all of its query params are stripped (no leftover ?action= / ?transactionID=).
  4. Expected: the underlying screen keeps its state (scroll, selection).

Case 2.5 — Refresh / deep link

Steps:

  1. From <base>/expense-report-edit?... (case 2.1 step 3), press F5.
  2. Expected: the report picker reopens with the correct base underneath.
  3. Open the same URL in a new tab and verify the same.
  4. ⚠️ For the bulk case (2.2) the selected transactions live in runtime context, so after a refresh the selection may be empty — verify there is no crash and no /not-found.

Case 2.6 — Legacy URL redirect

Target: OldRoutes — '/*/*/report/*/edit*'

Steps:

  1. Paste https://dev.new.expensify.com:8082/edit/submit/report/<reportID>/edit and hit Enter.
  2. Expected: it redirects to /r/<reportID>/expense-report-edit?action=edit&iouType=submit&reportID=<reportID> and opens the report picker.
  3. Paste the legacy URL with a query: .../edit/submit/report/<reportID>/edit?shouldTurnOffSelectionMode=true&transactionID=<txn> → Expected: it still redirects correctly and the page opens (the legacy query is dropped — known trade-off, not a failure).


DYNAMIC_ROUTES.MONEY_REQUEST_STEP_TAG — pick a tag for an expense (expense-tag)

Case 3.1 — Confirmation page → Tag field

Target: src/components/MoneyRequestConfirmationList/sections/TagFields.tsx#L75

Precondition: the workspace has Tags enabled with ≥1 tag list and ≥1 enabled tag.

Steps:

  1. Create a new expense (FAB → Create expense) and reach Confirmation on a workspace with tags.
  2. Tap the Tag field (its label is the tag list name).
  3. Expected: URL is <base>/expense-tag?action=create&iouType=submit&orderWeight=0&transactionID=<txn>&reportID=<report>.
    ⚠️ Verify orderWeight=0 is present in the query — the first tag list has index 0, and dropping it would make the page read the wrong tag list.
  4. Pick a tag → Expected: you return to Confirmation and the Tag field shows the selected tag.

Case 3.2 — Expense details → Tag field (multi-level tags)

Target: src/components/ReportActionItem/MoneyRequestView.tsx#L1124

Precondition: the workspace has multi-level tags (≥2 tag lists).

Steps:

  1. Open a submitted expense on that workspace (URL /r/<id>).
  2. Tap the second tag list row.
  3. Expected: URL is /r/<id>/expense-tag?action=edit&iouType=submit&orderWeight=1&transactionID=<txn>&reportID=<id> and the picker shows the second tag list (header = its name).
  4. Pick a tag → Expected: you return to /r/<id>, the second tag list is updated and the first one is unchanged.
  5. Repeat with the first tag list and verify orderWeight=0.

Case 3.3 — Split expense edit → Tag field

Target: src/pages/iou/SplitExpenseEditPage.tsx#L407

Precondition: an expense that has been split; open one split item for editing.

Steps:

  1. Open an expense → ⋯ → Split expense → split into 2 parts → tap one part to open the Split expense edit screen.
  2. Tap the Tag field.
  3. Expected: URL is <split-edit base>/expense-tag?action=edit&iouType=split-expense&orderWeight=<index>&transactionID=<OPTIMISTIC_TRANSACTION_ID>&reportID=<reportID>.
  4. Pick a tag → Expected: you return to the Split expense edit screen and the tag is applied to the right split item.

Case 3.4 — Empty tags → Edit tags button (self-referencing route)

Target: src/pages/iou/request/step/IOURequestStepTag.tsx#L222 on main; the PR replaces the rebuilt route with Navigation.getActiveRoute()

Precondition: you are a workspace admin; Tags is enabled but no tag is enabled (empty state).

Steps:

  1. On such a workspace, open an expense/confirmation and tap the Tag field.
  2. Expected: the tag page shows the empty state plus an Edit tags button.
  3. Note the current URL (it contains the expense-tag?... suffix).
  4. Tap Edit tags.
  5. Expected: the Workspace → Tags page opens.
  6. Tap Back.
  7. Expected: you return to the exact URL from step 3, including all query params (action, iouType, orderWeight, transactionID, reportID), and the tag page renders again.

Case 3.5 — Back and save-and-back

Steps:

  1. From Confirmation, tap the Tag field (case 3.1).
  2. Tap Back without picking anything → Expected: you return to Confirmation, the suffix and its query params are stripped from the URL, and the tag is unchanged.
  3. Open the Tag field again and pick a tag.
  4. Expected: you return to Confirmation with the tag updated, and focus is restored sensibly.

Case 3.6 — Refresh / deep link

Steps:

  1. From /r/<id>/expense-tag?action=edit&iouType=submit&orderWeight=0&transactionID=<txn>&reportID=<id>, press F5.
  2. Expected: the tag picker reopens on the correct tag list (per orderWeight) with /r/<id> restored underneath.
  3. Tap Back → you land on /r/<id>.
  4. Open the same URL in a new tab and verify the same.

Case 3.7 — Legacy URL redirect

Target: OldRoutes — '/*/*/tag/*/*/*'

Steps:

  1. Paste https://dev.new.expensify.com:8082/edit/submit/tag/0/<transactionID>/<reportID> and hit Enter.
  2. Expected: it redirects to /r/<reportID>/expense-tag?action=edit&iouType=submit&orderWeight=0&transactionID=<transactionID>&reportID=<reportID> and opens the tag picker.
  3. Try orderWeight=1 (if the workspace has 2 tag lists) and verify the picker opens the second list.

  • Verify that no errors appear in the JS console

Offline tests

  • Same as tests — navigation refactor, offline behavior unchanged.

QA Steps

Test case 1: Pick the report for a new expense (Confirmation)

  1. Sign in, tap the green + → Create expense, enter an amount and Next, pick a workspace chat to reach the Confirmation screen.
  2. Tap the Report field.
  3. Verify a report picker opens
  4. Pick a different report, then verify you return to Confirmation and the Report field shows the report you picked.

Test case 2: Move an expense to another report

  1. Open a draft expense on a paid workspace (its transaction thread).
  2. Tap (More) in the header → Move to report
  3. Verify the address bar shows a URL ending in /expense-report-edit?action=edit&….
  4. Pick a destination report, then verify the expense is moved and the panel closes back to the report.

Test case 3: Pick a tag for a new expense (Confirmation)

  1. On a workspace with Tags enabled, create an expense and reach Confirmation.
  2. Tap the Tag field.
  3. Verify the address bar shows a URL ending in /expense-tag?action=create&….
  4. Pick a tag, then verify you return to Confirmation and the Tag field shows the selected tag.
  • 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

MacOS: Chrome / Safari
CleanShot.2026-08-03.at.12.36.34.1.mp4
CleanShot.2026-08-03.at.12.53.46.1.mp4
Case 1.1 — Confirmation → Report 1 1-1-before-confirmation-report-field 1 1-2-entry-report-selection-dynamic 1 1-3-after-save-confirmation-report-changed
Case 1.2 — Expense view → Report 1 2-1-before-thread-direct-rbase 1 2-2-entry-report-suffix-clean 1 2-3-after-back-thread-restored-clean
Case 1.3 — Upgrade → Report
Case 1.4 — Global create → Report 1 4-1-before-globalcreate-confirmation 1 4-2-entry-report-picker-globalcreate 1 4-3-after-save-single-confirmation-newworkspace
Case 1.5 — Refresh / deep link (expense-report) 1 5-1-before-report-rhp-before-refresh 1 5-2-entry-report-rhp-restored-after-refresh
Case 1.6 — Legacy URL redirect (report) 1 6-1-before-oldurl-report-pre 1 6-2-entry-oldurl-redirected
Case 2.1 — Header → Move expense 2 1-1-before-expense-thread-move-before 2 1-2-entry-edit-report-move-dynamic
Case 2.2 — Bulk Move expenses 2 2-1-before-report-bulk-select-before 2 2-2-entry-bulk-selection-state
Case 2.3 — Report header → Move expense (single)
Case 2.4 — Back from report picker 2 4-1-before-edit-report-back-attempt 2 4-2-entry-back-stripped-suffix
Case 2.5 — Refresh / deep link (expense-report-edit) 2 5-1-before-edit-report-before-refresh 2 5-2-entry-edit-report-restored
Case 2.6 — Legacy URL redirect (edit-report) 2 6-1-before-oldurl-edit-report-pre 2 6-2-entry-oldurl-redirected
Case 3.1 — Confirmation → Tag 3 1-1-before-confirmation-tag-field 3 1-2-entry-tag-create-orderweight0
Case 3.2 — Expense view → Tag (multi-level) 3 2-1-before-expense-detail-tag-fields 3 2-2-entry-tag-dept-orderweight1 3 2-3-after-save-thread-after-dept-tag
Case 3.3 — Split expense edit → Tag
Case 3.4 — Empty tags → Edit tags (self-reference) 3 4-1-before-tag-step-empty-state 3 4-2-entry-tag-empty-state-edit-tags 3 4-3-after-edit-workspace-tags-page 3 4-4-after-back-tag-step-restored-selfref
Case 3.5 — Back / save-and-back (tag) 3 5-2-entry-tag-back-no-select-confirmation 3 5-3-after-save-tag-saved-back-confirmation
Case 3.6 — Refresh / deep link (expense-tag) 3 6-1-before-tag-step-before-refresh 3 6-2-entry-tag-step-restored
Case 3.7 — Legacy URL redirect (tag) 3 7-1-before-oldurl-tag-pre 3 7-2-entry-oldurl-redirected
Case 4.1 — Offline 4 1-1-before-offline-thread-before-tap 4 1-2-entry-offline-report-opens 4 1-3-after-back-offline-back-works
Case 4.2 — Out-of-scope fields unaffected 4 2-1-before-expense-detail-category-field 4 2-2-entry-category-route-intact
Android Native
Android mWeb
iOS Native
iOS mWeb

…utes

Replaces the static MONEY_REQUEST_STEP_REPORT, MONEY_REQUEST_EDIT_REPORT and
MONEY_REQUEST_STEP_TAG routes with the `expense-report`, `expense-report-edit`
and `expense-tag` dynamic suffixes, following the MONEY_REQUEST_STEP_TAX_RATE
pattern: the legacy path params become query params of the suffix, and back
navigation is derived with useDynamicBackPath instead of `backTo`.

Adds OldRoutes redirects for the three legacy paths and covers them with unit
tests in getMatchingNewRouteTest.
@suneox
suneox force-pushed the 83851-migrate-money-request-part-1-suneox branch from c3f4be4 to 33ec4c8 Compare July 31, 2026 04:50
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@suneox
suneox marked this pull request as ready for review July 31, 2026 04:53
@suneox
suneox requested review from a team as code owners July 31, 2026 04:53
@melvin-bot
melvin-bot Bot requested review from huult and trjExpensify and removed request for a team July 31, 2026 04:53
@melvin-bot

melvin-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

@huult 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team July 31, 2026 04:53

@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: 2b922945ea

ℹ️ 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 on lines +146 to +147
'/*/*/report/*/*': '/r/$4/expense-report?action=$1&iouType=$2&transactionID=$3&reportID=$4',
'/*/*/tag/*/*/*': '/r/$5/expense-tag?action=$1&iouType=$2&orderWeight=$3&transactionID=$4&reportID=$5',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve reportActionID in legacy redirects

When a pre-migration report or tag URL includes the optional reportActionID segment, e.g. /edit/submit/report/<txn>/<report>/<actionID> or /edit/submit/tag/<idx>/<txn>/<report>/<actionID>, these trailing-wildcard mappings bind $4/$5 to reportID/reportActionID. The redirect then builds /r/<report>/<actionID>/...&reportID=<report>/<actionID> and omits the reportActionID query param, so the dynamic screen looks up a non-existent report ID and can show Not Found. Add more-specific legacy mappings for the optional segment before these broad patterns and pass reportActionID separately.

Useful? React with 👍 / 👎.

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.

@suneox could you take a look?

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.

Updated for backward compatibility

@huult

huult commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The Jest test failed

@huult

huult commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@suneox could you please sync with main to resolve the conflict?

suneox and others added 4 commits August 3, 2026 11:50
The broad legacy redirect patterns ('/*/*/report/*/*', '/*/*/tag/*/*/*')
use a trailing greedy wildcard for reportID, so a legacy URL carrying the
optional reportActionID segment (e.g. /edit/submit/report/<txn>/<report>/<actionID>)
had reportID+reportActionID swallowed together into one capture, producing a
malformed redirect (/r/<report>/<actionID>/expense-report?...&reportID=<report>/<actionID>)
that omitted the reportActionID query param.

Add more-specific patterns (5/6 wildcards) BEFORE the broad ones so the
longest-pattern match (getMatchingNewRoute picks max pattern.length) routes
the actionID into its own reportActionID query param. taxRate is unaffected
(its route has no reportActionID).

Addresses codex review r3688158528.

Co-Authored-By: Claude <noreply@anthropic.com>
The trailing wildcard in OldRoutes patterns is greedy ('.*') and the
lookahead ('(?=[?#]|$)') is satisfied at end-of-string, so the report/tag
capture absorbed the entire query string when a legacy URL carried one
(e.g. '/edit/submit/report/<txn>/<report>?backTo=…'). The redirect then
mangled reportID ('reportID=<report>?backTo=…'), dropped the redirect's
own params, and produced a double '?'.

Split path/query before matching, match on path only, then re-append the
original query merged with any query the redirect template adds.

Verified: legacy '/edit/submit/report/<txn>/<report>?backTo=…' now redirects
to '/r/<report>/expense-report?action=edit&iouType=submit&transactionID=…&reportID=<report>&backTo=…'.

Co-Authored-By: Claude <noreply@anthropic.com>
…suffix

The Part 1 migration made 'expense-report' a dynamic route suffix, so the
test's literal reportID 'expense-report' was intercepted by the dynamic
matcher (base '/r' + suffix 'expense-report') instead of being treated as a
report link → openLink returned the raw path instead of EXPENSE_REPORT_RHP.

Use a non-colliding reportID ('expense-report-rhp'). Real reportIDs are
numeric so this is a test-only concern.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

@suneox

suneox commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@suneox could you please sync with main to resolve the conflict?

Done

// URL carrying `?backTo=…` (or any query) gets mangled — the reportID capture absorbs
// the query and the redirect's own params land inside it. Match on the path only and
// re-append the original query, merging it with any query the redirect template adds.
const [pathOnly, query] = path.split('?');

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.

If we don't update this part, is there another way to handle it? To be honest, we've never updated this helper before, and we've always let @collectioneur handle this logic.

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.

@huult — concrete before/after to show why this change is needed.

Scenario

User clicks a legacy deep link (bookmark, shared link, old email) that carries a backTo query param:

Input URL:

/edit/submit/report/9090655891351421950/291045375604332?backTo=%2Fsearch%2Fview%2F291045375604332

The OldRoutes pattern '/*/*/report/*/*' compiles $4 (the last wildcard) as a greedy (.*). The (?=[?#]|$) lookahead is satisfied at end-of-string, so $4 doesn't stop at the ? — it swallows the query too.


Before this change (broken)

$4 captures 291045375604332?backTo=%2Fsearch%2Fview%2F291045375604332 (reportID + query together).

The redirect template /r/$4/expense-report?action=$1&iouType=$2&transactionID=$3&reportID=$4 produces:

/r/291045375604332?backTo=%2Fsearch%2Fview%2F291045375604332/expense-report?action=edit&iouType=submit&transactionID=9090655891351421950&reportID=291045375604332?backTo=%2Fsearch%2Fview%2F291045375604332

Problems:

  • reportID contains ? and / → invalid.
  • The /r/<reportID> path has the query baked in → the router can't resolve it.
  • Double ? in the URL.
  • backTo is duplicated and in the wrong position.
  • Result: the page shows Not Found or the wrong screen.

After this change (fixed)

path.split('?') separates path from query before matching:

  • pathOnly = /edit/submit/report/9090655891351421950/291045375604332
  • query = backTo=%2Fsearch%2Fview%2F291045375604332

Now $4 captures only 291045375604332 (clean reportID). After the redirect template runs, the original query is merged back:

/r/291045375604332/expense-report?action=edit&iouType=submit&transactionID=9090655891351421950&reportID=291045375604332&backTo=%2Fsearch%2Fview%2F291045375604332

All params correct, backTo preserved, single ?, valid URL.


Why the fix has to be here

The trailing (.*) must stay greedy (other patterns rely on multi-segment matching). Tightening it to [^?#]* stops the swallow but leaves a double ? (the template's ?action=… + the original ?backTo=…). The two query strings have to be merged, and getMatchingNewRoute is the only place that sees both.

This is an edge case we missed, for example, with our own migration from last week.

CleanShot.2026-08-03.at.19.04.00.1.mp4

@huult

huult commented Aug 3, 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
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.17.55.21.mov

@trjExpensify

Copy link
Copy Markdown
Contributor

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

@trjExpensify
trjExpensify removed their request for review August 3, 2026 22:44

@huult huult 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 mjasikowski August 4, 2026 02:41
@mjasikowski
mjasikowski merged commit 61ca4f3 into Expensify:main Aug 4, 2026
36 of 37 checks passed
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Aug 4, 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.

@OSBotify OSBotify mentioned this pull request Aug 4, 2026
52 tasks done
@OSBotify

OSBotify commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.4.50-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 and no updates to the help site (App/docs/articles) are needed, so I did not create a draft docs PR.

Why: This PR is a purely internal refactor that migrates the money-request report, edit-report, and tag steps to dynamic URL navigation (removing backTo/forwardTo). All changes are in routing/navigation plumbing, components, hooks, and tests:

  • src/ROUTES.ts, src/SCREENS.ts, src/libs/Navigation/** (routing config, OldRoutes, dynamic route matchers)
  • src/pages/iou/request/step/Dynamic* pages and supporting components/hooks
  • Test files

There are no user-facing changes — no new or renamed features, tab names, settings labels, or buttons, and no src/languages/* copy changes. URL structure and back-navigation behavior are implementation details that the help articles don't document. Existing articles (e.g. categorizing/tagging expenses, working with reports) describe the same user workflows and remain accurate.


@suneox, since this is an internal routing change with no user-facing impact, there is no linked help site PR to review. If you believe a specific help article should be updated for a behavior change here, let me know which one and I'll draft the update.

@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.50-3 🚀

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.

7 participants