Repository navigation
Migrate First verify-account Route (BATCH-5) - #81413
14 commits merged into
Conversation
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.
|
…r/dynamic-routes-batch-5
…r/dynamic-routes-batch-5
|
@mananjadhav 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 177d5b5b29
ℹ️ 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".
…r/dynamic-routes-batch-5
|
I am reviewing #81859 instead of this one. |
There was a problem hiding this comment.
@collectioneur I've posted some comments. Also some general aspects of the dynamic routes to be addressed/clarified:
- Dynamic suffix must be last segment
- Only one dynamic suffix allowed
- No nested dynamic routes
- Too many type cases, example
as Route,as Screen, etc.
| @@ -0,0 +1,22 @@ | |||
| import React from 'react'; | |||
There was a problem hiding this comment.
Do we need to add a new page prefixing Dynamic?
There was a problem hiding this comment.
I think, that's a great way to clearly distinguish between static and dynamic pages, I’ll update the documentation to include this context. As a follow-up I’m also planning to add an ESLint rule to help validate these naming conventions for dynamic screens and components 😄
| if (!pathWithoutParams) { | ||
| throw new Error('[getLastSuffixFromPath.ts] Failed to parse the path, path is empty'); | ||
| if (!normalizedPath) { | ||
| Log.warn('[getLastSuffixFromPath.ts] Failed to parse the path, path is empty'); |
There was a problem hiding this comment.
question: We changed the error to warn and now returning ''. Are we sure it won't cause regression elsewhere?
There was a problem hiding this comment.
This should be safe from regressions. Since we verify that the path exists before calling this function, that if statement is effectively unreachable. It was added primarily to satisfy TypeScript/ESLint requirements
| * @param dynamicRouteSuffix The dynamic route suffix to remove from the current path | ||
| * @returns The back path without the dynamic route suffix, or HOME if path is null/undefined | ||
| */ | ||
| function useDynamicBackPath(dynamicRouteSuffix: DynamicRouteSuffix): Route { |
There was a problem hiding this comment.
question: Are we planning on adding tests for the same?
There was a problem hiding this comment.
I can see the tests are added in the next PR #81859 (review)
| * @returns A tuple where the first element is the path without trailing slash | ||
| * and the second element is the query string (if any). | ||
| */ | ||
| function splitPathAndQuery(fullPath: string | undefined): [string | undefined, string | undefined] { |
There was a problem hiding this comment.
I think it's best we add some unit tests for the same.
There was a problem hiding this comment.
I can see the tests are added in the next PR #81859 (review)
| @@ -0,0 +1,13 @@ | |||
| /** | |||
| * Splits a full path into its path and query components. | |||
| * @param fullPath - The full URL path (e.g., '/settings/wallet?param=value') | |||
There was a problem hiding this comment.
question: The example uses fullPath but when calling inside useDynamicBackPath we use pathWithoutLeadingSlash. Any reason we're not passing the full path?
There was a problem hiding this comment.
Great catch. We don't need to explicitly remove trailing slashes in useDynamicBackPath, as that logic is already handled in splitPathAndQuery. I'll clean that up in the next commit, thanks
There was a problem hiding this comment.
Sorry for the confusion! I re-checked the implementation and realized that removing the leading slash is actually necessary. Our route names don't include it, so we need that normalization to ensure the comparison logic works correctly in src/pages/settings/DynamicVerifyAccountPage.tsx. I'll leave that part as is 🙂
|
|
||
| type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>; | ||
|
|
||
| const dynamicRouteEntries = Object.values(DYNAMIC_ROUTES); |
There was a problem hiding this comment.
question: Do you think using Set makes more sense? We're looping for every call in isDynamicRouteScreen?
There was a problem hiding this comment.
Agreed. Switching to a Set is a smart optimization for the future, even though we currently don't have many dynamic routes. I'll update the function. Thanks for the suggestion! 👍
| const screenName = focusedRoute?.name ?? ''; | ||
|
|
||
| // Handle dynamic route screens that require special path that is placed in state | ||
| if (isDynamicRouteScreen(screenName as Screen) && focusedRoute?.path) { |
There was a problem hiding this comment.
do we need to type case as Screen? Does it make sense to pass string and then typecase in the method?
There was a problem hiding this comment.
In this case, normalizedConfigs requires the Screen type. Because of that dependency, the type assertion was needed to keep the types aligned for now. I plan to come back to this later, ideally, a future refactor will allow us to streamline the types and remove these assertions where they aren't strictly necessary 👍
| } | ||
|
|
||
| // If suffix is not the last segment, return the original path | ||
| return pathWithoutLeadingSlash as Route; |
There was a problem hiding this comment.
question: If Route expects paths like /settings/wallet, this would produce settings/wallet right? Could this break something in navigation?
There was a problem hiding this comment.
This hook is used only in dynamic components, so the fallback logic shouldn't be triggered. We should be safe from regressions here
|
|
||
| const [normalizedPath, query] = splitPathAndQuery(pathWithoutLeadingSlash); | ||
|
|
||
| if (normalizedPath?.endsWith(`/${dynamicRouteSuffix}`)) { |
There was a problem hiding this comment.
Do we have any scenarios in future where we've got nested routes? Something like /settings/wallet/verify-account/step-2? Will it still work the same way as it's defined now?
There was a problem hiding this comment.
You're right, those cases aren't covered yet. I've flagged this in the Batch 7 docs, as we prioritized the base logic for this first release. We'll be rolling out support for those edge cases during phase 2 as the need arises
| } | ||
|
|
||
| // Handle dynamic routes: find the appropriate full screen route | ||
| if (route.path) { |
There was a problem hiding this comment.
suggestion: I reviewed this in the previous PR but now that we're moving it around in the code base, do you think it makes sense to move it to a separate helper method?
There was a problem hiding this comment.
I’ve adjusted the placement of that logic to ensure dynamic routes maintain the lowest priority for full screen lookups. Given that this is currently the only instance of this code, I’ve kept it inline rather than creating a separate helper method to keep things concise 👍
|
@mananjadhav I’ve addressed all the comments and pushed the updates ✅ . Feel free to take another look whenever you have a moment |
I've made sure the documentation reflects these current constraints to keep everything aligned 😄 |
5b4e825
Screenshots/VideosAndroid: HybridAppandroid-dynamic-route-verify-account.movAndroid: mWeb Chromemweb-chrome-dynamic-route-verify-account.moviOS: HybridAppios-dynamic-route-verify-account.moviOS: mWeb Safarimweb-safari-dynamic-route-verify-account.movMacOS: Chrome / Safariweb-dynamic-route-verify-account.mov |
|
This was merged including another PR but screencasts were pending. Uploaded them. |
Explanation of Change
I refactored the first page from a static to a dynamic route.
ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNTnow uses dynamic route logic.Fixed Issues
$ #80910
Tests
Prerequisites:
Test 1
Test 2
Test 3
Test 4
Test 5
Offline tests
QA Steps
Same as tests
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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-02-04.at.16.35.12.mov