Repository navigation
83851 - migrate money request report, edit report and tag steps to dynamic route - #97460
mjasikowski merged 7 commits into
Conversation
…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.
c3f4be4 to
33ec4c8
Compare
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
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 --helpTypically, you'd want to translate only what you changed by running |
There was a problem hiding this comment.
💡 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".
| '/*/*/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', |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
Updated for backward compatibility
|
The Jest test failed |
|
@suneox could you please sync with main to resolve the conflict? |
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 Report✅ Changes either increased or maintained existing code coverage, great job!
|
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('?'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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:
reportIDcontains?and/→ invalid.- The
/r/<reportID>path has the query baked in → the router can't resolve it. - Double
?in the URL. backTois 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/291045375604332query=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
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-08-03.at.17.55.21.mov |
|
PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself. |
|
🚧 mjasikowski has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.4.50-0 🚀
|
|
🤖 Help site review: no changes required I reviewed the changes in this PR and no updates to the help site ( Why: This PR is a purely internal refactor that migrates the money-request report, edit-report, and tag steps to dynamic URL navigation (removing
There are no user-facing changes — no new or renamed features, tab names, settings labels, or buttons, and no @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. |
|
🚀 Deployed to production by https://github.com/arosiclair in version: 9.4.50-3 🚀
Bundle Size Analysis (Sentry): |
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 suffixesexpense-report,expense-report-editandexpense-tag; the old path params (action,iouType,transactionID,reportID,orderWeight) move into query params of the suffix, mirroring theMONEY_REQUEST_STEP_TAX_RATEpattern already onmain. Each route declaresentryScreens(Confirmation + report views) and anOldRoutesbackward-compat matcher so legacy deep links redirect to the new URL. Back usesuseDynamicBackPath, 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:
/create/submit/confirmation/<transactionID>/<reportID>.<base>/expense-report?action=create&iouType=submit&transactionID=<txn>&reportID=<report>— no?backTo=.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:
/r/<id>)./r/<id>/expense-report?action=edit&iouType=submit&transactionID=<txn>&reportID=<id>and the report picker opens in the RHP./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:
/r/<reportID>/expense-report?action=edit&iouType=submit&transactionID=<txn>&reportID=<reportID>.upgradesegment — the suffix is explicitly anchored to/r/<reportID>becausegetActiveRoute()would still resolve to the upgrade screen being popped./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) withaction === create.Steps:
expense-reportsuffix).Case 1.5 — Refresh / deep link restores the stack
Steps:
/r/<id>/expense-report?...)./r/<id>underneath (not Home, not/not-found)./r/<id>.Case 1.6 — Legacy URL redirect
Target: src/libs/Navigation/linkingConfig/OldRoutes.ts —
'/*/*/report/*/*'Steps:
https://dev.new.expensify.com:8082/edit/submit/report/<transactionID>/<reportID>and hit Enter./r/<reportID>/expense-report?action=edit&iouType=submit&transactionID=<transactionID>&reportID=<reportID>and opens the report picker.?backTo=…loses its query (the trailing wildcard of the matcher swallows it) — same known trade-off as thetaxRateredirect already onmain. 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:
/r/<id>)./r/<id>/expense-report-edit?action=edit&iouType=submit&reportID=<parentReportID>&shouldTurnOffSelectionMode=true&transactionID=<txn>and the report list opens in the RHP.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:
<report base>/expense-report-edit?action=edit&iouType=submit&reportID=<reportID>— notransactionIDquery (bulk selection comes from context).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:
<base>/expense-report-edit?action=edit&iouType=submit&reportID=<moneyRequestReportID>&shouldTurnOffSelectionMode=true&transactionID=<txn>.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:
/r/<id>) — the suffix and all of its query params are stripped (no leftover?action=/?transactionID=).Case 2.5 — Refresh / deep link
Steps:
<base>/expense-report-edit?...(case 2.1 step 3), press F5./not-found.Case 2.6 — Legacy URL redirect
Target: OldRoutes —
'/*/*/report/*/edit*'Steps:
https://dev.new.expensify.com:8082/edit/submit/report/<reportID>/editand hit Enter./r/<reportID>/expense-report-edit?action=edit&iouType=submit&reportID=<reportID>and opens the report picker..../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:
<base>/expense-tag?action=create&iouType=submit&orderWeight=0&transactionID=<txn>&reportID=<report>.orderWeight=0is present in the query — the first tag list has index 0, and dropping it would make the page read the wrong tag list.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:
/r/<id>)./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)./r/<id>, the second tag list is updated and the first one is unchanged.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:
<split-edit base>/expense-tag?action=edit&iouType=split-expense&orderWeight=<index>&transactionID=<OPTIMISTIC_TRANSACTION_ID>&reportID=<reportID>.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 withNavigation.getActiveRoute()Precondition: you are a workspace admin; Tags is enabled but no tag is enabled (empty state).
Steps:
expense-tag?...suffix).action,iouType,orderWeight,transactionID,reportID), and the tag page renders again.Case 3.5 — Back and save-and-back
Steps:
Case 3.6 — Refresh / deep link
Steps:
/r/<id>/expense-tag?action=edit&iouType=submit&orderWeight=0&transactionID=<txn>&reportID=<id>, press F5.orderWeight) with/r/<id>restored underneath./r/<id>.Case 3.7 — Legacy URL redirect
Target: OldRoutes —
'/*/*/tag/*/*/*'Steps:
https://dev.new.expensify.com:8082/edit/submit/tag/0/<transactionID>/<reportID>and hit Enter./r/<reportID>/expense-tag?action=edit&iouType=submit&orderWeight=0&transactionID=<transactionID>&reportID=<reportID>and opens the tag picker.orderWeight=1(if the workspace has 2 tag lists) and verify the picker opens the second list.Offline tests
QA Steps
Test case 1: Pick the report for a new expense (Confirmation)
Test case 2: Move an expense to another report
/expense-report-edit?action=edit&….Test case 3: Pick a tag for a new expense (Confirmation)
/expense-tag?action=create&….PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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
Case 1.2 — Expense view → Report
Case 1.3 — Upgrade → Report
Case 1.4 — Global create → Report
Case 1.5 — Refresh / deep link (expense-report)
Case 1.6 — Legacy URL redirect (report)
Case 2.1 — Header → Move expense
Case 2.2 — Bulk Move expenses
Case 2.3 — Report header → Move expense (single)
Case 2.4 — Back from report picker
Case 2.5 — Refresh / deep link (expense-report-edit)
Case 2.6 — Legacy URL redirect (edit-report)
Case 3.1 — Confirmation → Tag
Case 3.2 — Expense view → Tag (multi-level)
Case 3.3 — Split expense edit → Tag
Case 3.4 — Empty tags → Edit tags (self-reference)
Case 3.5 — Back / save-and-back (tag)
Case 3.6 — Refresh / deep link (expense-tag)
Case 3.7 — Legacy URL redirect (tag)
Case 4.1 — Offline
Case 4.2 — Out-of-scope fields unaffected
Android Native
Android mWeb
iOS Native
iOS mWeb