-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix infinite loading of Reports Expenses tab after refreshing Split Submit page #79897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix infinite loading of Reports Expenses tab after refreshing Split Submit page #79897
Conversation
|
@mkhutornyi 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] |
| const copiedParams = paramsFromRoute.length > 0 ? pick(route.params, paramsFromRoute) : {}; | ||
| let queryParam: Record<string, string> = {}; | ||
| if (route.path) { | ||
| const decodedPath = decodeURIComponent(route.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-2 (docs)
The regex pattern /[?&]q=([^&/]+)/ is a magic string without clear documentation explaining its purpose or structure.
Suggested fix:
Add a named constant with documentation:
// Regex to extract the "q" query parameter from a URL path
// Matches: ?q=value or &q=value, capturing everything until & or /
const QUERY_PARAM_REGEX = /[?&]q=([^&/]+)/;
// Then use:
const searchMatch = decodedPath.match(QUERY_PARAM_REGEX);Or add an inline comment explaining the regex:
// Extract the "q" query parameter (matches ?q=... or &q=...)
const searchMatch = decodedPath.match(/[?&]q=([^&/]+)/);
src/pages/Search/SearchPage.tsx
Outdated
|
|
||
| if (isDismissed) { | ||
| Navigation.navigate(ROUTES.TRANSACTION_HOLD_REASON_RHP); | ||
| if (isSearchTopmostFullScreenRoute()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CONSISTENCY-3 (docs)
This conditional navigation pattern is duplicated multiple times in this file (lines 824-828, 901-907, 1191-1195, 1204-1208). The logic is identical: check if search is topmost, then navigate with or without backTo parameter.
Suggested fix:
Extract into a reusable helper function:
function navigateToSearchRHP(route: {route: string; getRoute: (backTo?: string) => string}, fallbackRoute?: string) {
if (isSearchTopmostFullScreenRoute()) {
Navigation.navigate(route.getRoute(Navigation.getActiveRoute()));
} else {
Navigation.navigate(fallbackRoute ?? route.getRoute());
}
}
// Then use:
navigateToSearchRHP(ROUTES.TRANSACTION_HOLD_REASON_SEARCH, ROUTES.TRANSACTION_HOLD_REASON_RHP);There was a problem hiding this comment.
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: 9ce93df9f8
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const decodedPath = decodeURIComponent(route.path); | ||
| const searchMatch = decodedPath.match(/[?&]q=([^&/]+)/); | ||
| if (searchMatch?.[1]) { | ||
| queryParam = {q: decodeURIComponent(searchMatch[1])}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve encoded search queries when extracting q
The new q extraction decodes the entire route.path and then regexes it, so any query that originally contained encoded delimiters (e.g., AT%26T or foo%2Fbar) is decoded into & or / before the regex runs and gets truncated at that character. Additionally, the second decodeURIComponent will throw for values that decode to a literal % (e.g., 100%), which can break navigation on refresh. This means refreshing an RHP screen with ?q=... can restore the wrong search query or crash for common user input. Consider parsing query params from the raw path (or using URLSearchParams) and decoding the q value only once.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If 👎, add comment why
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
JmillsExpensify
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. No product review required on this PR.
Please add unit tests |
| const decodedPath = decodeURIComponent(route.path); | ||
| // Extract the "q" query parameter (matches ?q=... or &q=...) | ||
| const searchMatch = decodedPath.match(/[?&]q=([^&/]+)/); | ||
| if (searchMatch?.[1]) { | ||
| queryParam = {q: decodeURIComponent(searchMatch[1])}; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex thing should be in utils and requires automated test
Explanation of Change
When we go to
Reports > Submit,and check an expense, then click the dropdown and select the split,If we refresh at the split screen, the Background screen should stay in
Reports > Submit.Fixed Issues
$ #78983
PROPOSAL: #78983 (comment)
Tests
Reports > Submitstill being shown as backgound screen.Offline tests
Same as Tests
QA Steps
Same as Tests
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Not applicable
Android: mWeb Chrome
Screen.Recording.1404-10-29.at.5.46.06.PM.mov
iOS: Native
Not applicable
iOS: mWeb Safari
Screen.Recording.1404-10-29.at.5.43.53.PM.mov
MacOS: Chrome / Safari
Screen.Recording.1404-10-29.at.5.34.58.PM.mov