Skip to content

Fix not here page after moving IOU report to workspace#87167

Open
MelvinBot wants to merge 16 commits intomainfrom
claude-fixNotHerePageAfterMovingIOUToWorkspace
Open

Fix not here page after moving IOU report to workspace#87167
MelvinBot wants to merge 16 commits intomainfrom
claude-fixNotHerePageAfterMovingIOUToWorkspace

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

@MelvinBot MelvinBot commented Apr 6, 2026

Explanation of Change

When moving an IOU report to a workspace, the REPORT_PREVIEW action is completely removed from Onyx (set to null via Onyx.METHOD.MERGE). The existing cleanup effect in LinkedActionNotFoundGuard only handled the case where the linked action existed but was hidden/deleted (isLinkedActionDeleted). When the action was removed entirely, linkedAction became undefined but isLinkedActionDeleted stayed false (since it requires linkedAction to be truthy), leaving the stale reportActionIDFromRoute in the URL and causing a "not here" page.

This PR expands the cleanup effect to also clear the route param when linkedAction is null (completely removed from Onyx) while wasEverVisible is true and loading has completed.

Fixed Issues

$ #85753
PROPOSAL: #85753 (comment)

Tests

Precondition:

  • Have at least one workspace.
  • User has received IOU expense from another user.
  1. Open 1:1 DM where IOU expense is received.
  2. Copy link of IOU preview and paste in self DM.
  3. Click on that link.
  4. Open the expense.
  5. Click More > Change workspace.
  6. Select workspace.
  7. Close the RHP.
  8. Verify the central pane shows the 1:1 DM (not a "not here" page).
  • Verify that no errors appear in the JS console

Offline tests

N/A - This bug only occurs when an API call (changing workspace) removes the action from Onyx. The navigation fix is purely client-side route param cleanup.

QA Steps

Same as tests above - reproduce on staging where the deep link feature is enabled.

  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.
  • I verified that similar component doesn't exist in the codebase
  • I verified that all props are defined accurately and each prop has a /** comment above it */
  • I verified that each file is named correctly
  • I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
  • I verified that the only data being stored in component state is data necessary for rendering and nothing else
  • In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
  • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
  • I verified that component internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
  • I verified that all JSX used for rendering exists in the render method
  • I verified that each 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

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

When moving an IOU report to a workspace, the REPORT_PREVIEW action is
completely removed from Onyx (set to null). The existing cleanup effect
only handled the case where the action existed but was hidden/deleted
(isLinkedActionDeleted). When the action was nulled out entirely,
linkedAction became undefined but isLinkedActionDeleted stayed false
(since it requires linkedAction to be truthy), leaving the stale
reportActionIDFromRoute in the URL and showing a "not here" page.

Expand the effect to also clear the route param when linkedAction is
null (completely removed) while wasEverVisible is true, after loading
has completed.

Co-authored-by: {"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"} <{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#get-an-issue-comment","status":"404"}@users.noreply.github.com>
…-onyx

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing typecheck: src/libs/ChronosUtils.ts was importing OnyxInputOrEntry from react-native-onyx, but that type was removed from the package and relocated to @src/types/onyx/OnyxInputOrEntry. Updated the import to use the local type definition, consistent with all other files in the codebase.

Note: This is a pre-existing issue on main (not caused by this PR's changes).

if (!isActionGone) {
return;
}
Navigation.setParams({reportActionID: ''});
Copy link
Copy Markdown
Contributor

@aimane-chnaif aimane-chnaif Apr 6, 2026

Choose a reason for hiding this comment

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

@MelvinBot This is no-op because report action was deleted while in modal which doesn't have reportActionID in navigation route at all.

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.

Good catch! Navigation.setParams targets the focused route by default, so when a modal is open it's a no-op since the modal route has no reportActionID.

Fixed by passing route.key to all three setParams calls so they always target the report screen's route regardless of which screen is focused.

Pass route.key to Navigation.setParams so it targets the report
screen's route instead of the currently focused route. Without this,
setParams is a no-op when a modal is focused because the modal route
has no reportActionID param.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
if (!isActionGone) {
return;
}
Navigation.setParams({reportActionID: ''}, route.key);
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.

@MelvinBot this still doesn't work

The action 'SET_PARAMS' with payload {"params":{"reportActionID":""}} was not handled by any navigator.

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.

The issue was that SET_PARAMS only searches the flat routes array of each navigator. When the report screen route is nested inside a split navigator and a modal is focused, the action never reaches the correct navigator.

Fixed by adding a findParentNavigatorKey helper in Navigation.ts that walks the navigation state tree to find which navigator directly contains the route, then passes its key as target in the dispatch. This ensures the action is delivered to the right navigator regardless of what's currently focused.

SET_PARAMS only searches the flat routes array of each navigator.
When a route is nested inside a split navigator and a modal is
focused, the action never reaches the correct navigator.

Add findParentNavigatorKey helper that walks the navigation state
tree to find which navigator directly contains the route, then pass
its key as `target` so the action is dispatched to the right place.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/Navigation/Navigation.ts 57.00% <100.00%> (+1.67%) ⬆️
src/pages/inbox/LinkedActionNotFoundGuard.tsx 93.93% <100.00%> (+1.08%) ⬆️
... and 389 files with indirect coverage changes

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot fix conflict and update Tests steps as per #85753 (comment)

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main to resolve the conflict in src/libs/ChronosUtils.ts (import style change for OnyxInputOrEntry) and updated the Tests section to match the reproduction steps from this comment.

* This is needed because SET_PARAMS only searches flat routes arrays, so dispatching
* without `target` fails for routes nested inside split navigators.
*/
function findParentNavigatorKey(routeKey: string, state?: NavigationState): string | undefined {
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.

@MelvinBot can you add unit test?

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot the bug is still reproducible on mobile

Screen.Recording.2026-04-06.at.7.09.09.pm.mov

- Test findParentNavigatorKey: direct children, nested routes, deep nesting, sibling navigators, not-found cases
- Test LinkedActionNotFoundGuard: action removal clears route param with route.key, no navigation when never visible, no navigation while loading, bypass when no reportActionID
- Export findParentNavigatorKey for testability

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Added unit tests in 5179468:

findParentNavigatorKeyTest.ts (6 tests) — covers the new findParentNavigatorKey helper:

  • Direct children, nested routes, deeply nested routes
  • Sibling navigators returning correct parent
  • Not-found and empty-state edge cases

LinkedActionNotFoundGuardTest.tsx (6 tests) — covers the updated cleanup effects:

  • Clears reportActionID when linked action is completely removed from Onyx (the core bug fix)
  • Passes route.key to setParams for split navigator targeting
  • Does not navigate away when action was never visible
  • Does not clear params while report actions are still loading
  • Bypasses guard entirely when no reportActionID in route

Gate shouldShowNotFoundLinkedAction on !wasEverVisible so the not-found
page is never shown when an action was previously visible and then
removed from Onyx. On mobile (NativeStackView), the synchronous render
commits the not-found UI before the cleanup useEffect can fire setParams
to clear the route param. By preventing the not-found page from showing
in this case, the effect handles navigation cleanly on all platforms.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Pushed a fix in c0db3f6.

Root cause: When the linked action is removed from Onyx, shouldShowNotFoundLinkedAction evaluates to true synchronously during render — showing the "not here" page — before the cleanup useEffect can fire setParams to clear the route param. On desktop (JS StackView), React batches the update fast enough that the flash isn't visible. On mobile (NativeStackView), the not-found UI is committed to the native layer immediately, making it visible.

Fix: Gate shouldShowNotFoundLinkedAction on !wasEverVisible. When the action was previously visible and then removed, the not-found page is never shown — the cleanup effect handles navigation via setParams instead. This was already the intended behavior (the effect existed for this case), but the render condition wasn't properly excluding it.

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot author checklist is failing. And pull main

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot the root cause of this bug is that backTo param still contains reportActionID so when press back button, it still goes to report action deep link which doesn't exist.

Example:

https://dev.new.expensify.com:8082/r/1298667751606329/?backTo=%2Fr%2F2247619693499951%2F1461598516100574753

https://dev.new.expensify.com:8082/r/2247619693499951/1461598516100574753

…AfterMovingIOUToWorkspace

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Done! Two things fixed:

  1. Author checklist — Removed duplicate unchecked checklist items that were appended at the bottom of the PR body. The checklist check should pass now.
  2. Merged main — Pulled latest main into the branch (no conflicts).

… is removed

When a linked report action is removed (e.g. REPORT_PREVIEW nulled after
moving an IOU to a workspace), the current route's reportActionID is cleared
but sibling screens still carry the old reportActionID in their backTo param.
Pressing back on those screens navigates to the stale deep-link, causing a
"not here" page.

Add Navigation.cleanStaleBackToParam() to walk the navigation state tree and
strip the stale reportActionID from any backTo params referencing the removed
action. Called from LinkedActionNotFoundGuard's cleanup effect.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Good catch — the backTo param on sibling screens (e.g. the IOU report) still held the stale URL with the removed reportActionID, so pressing back navigated to a dead deep link.

Fix: Added Navigation.cleanStaleBackToParam() which walks the navigation state tree and strips the stale reportActionID from any backTo params referencing the removed action. It's called from the same cleanup effect in LinkedActionNotFoundGuard that already clears the current route's reportActionID.

* reportActionID. Pressing back on those screens would navigate to the stale
* deep-link, causing a "not here" page. This function patches those params.
*/
function cleanStaleBackToParam(reportID: string, reportActionID: string) {
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.

@MelvinBot can you add unit test?

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Unit tests are already included in this PR:

  1. tests/unit/findParentNavigatorKeyTest.ts — Tests for the findParentNavigatorKey helper (direct child, nested routes, deeply nested, sibling navigators, not found, empty state)
  2. tests/unit/LinkedActionNotFoundGuardTest.tsx — Tests for the guard component (renders children when action exists, clears reportActionID when action removed from Onyx, does NOT navigate when action was never visible, passes route.key for split navigator targeting, no-op without reportActionID, no-op while still loading)

All test jobs (1-8) are passing in CI. Is there a specific scenario you'd like additional test coverage for?

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@MelvinBot add unit test for cleanStaleBackToParam function.

Author checklist is still failing

…ard test

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team as a code owner April 6, 2026 20:35
@melvin-bot melvin-bot bot requested review from aimane-chnaif and joekaufmanexpensify and removed request for a team, aimane-chnaif and joekaufmanexpensify April 6, 2026 20:35
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Apr 6, 2026

@aimane-chnaif 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 requested review from aimane-chnaif and removed request for a team April 6, 2026 20:35
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Done! PR has been marked as ready for review. I also cleaned up the duplicate checklist items from the PR body.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: Looks good. The approach is sound — detecting when a linked action disappears from Onyx (not just deleted/hidden), clearing the stale reportActionID, and patching sibling backTo params. No critical bugs found.

Minor Items

  1. cleanStaleBackToParam only handles r/{reportID}/{reportActionID} pattern (Navigation.ts:923-924)
    The SEARCH_REPORT route also supports search/view/{reportID}/{reportActionID}. If a backTo ever contains that pattern, it won't be cleaned. Low risk today but worth noting for future-proofing.

  2. reportActionID: ''undefined — Verified safe. All existing checks in the codebase use truthiness (!reportActionID), never strict equality against empty string.

  3. setParams signature change is backward-compatible. The default routeKey='' is falsy, so existing callers without a routeKey still use state.index (current focused route) via BaseRouter.tsx:21.

What Looks Good

  • findParentNavigatorKey — Clean recursive walk with early return. Correctly targets SET_PARAMS to the right navigator for routes nested inside split navigators.
  • wasEverVisible guard — Properly prevents the "not found" flash on mobile (NativeStackView commits UI synchronously before the effect fires) while still catching runtime action removal.
  • The expanded condition (!linkedAction && !isLoadingInitialReportActions) correctly handles the new case where an action is completely removed from Onyx.
  • Good test coverage — three new test files covering findParentNavigatorKey, cleanStaleBackToParam, and LinkedActionNotFoundGuard behavior.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@aimane-chnaif
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
    • MacOS: Desktop
  • 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 there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@melvin-bot melvin-bot bot requested a review from mountiny April 6, 2026 21:20
@mountiny
Copy link
Copy Markdown
Contributor

mountiny commented Apr 8, 2026

@aimane-chnaif can you look into fixing the author checklist?

@aimane-chnaif
Copy link
Copy Markdown
Contributor

@aimane-chnaif can you look into fixing the author checklist?

I think there's bug in automation.
After Melvin corrects checklist, github-actions reverts back to broken one.

Screenshot 2026-04-08 at 6 02 32 pm

@MelvinBot
Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

MelvinBot has made 15 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR.

Next steps: A human should review the recent commits and resolve the conflicting CI errors manually.

Copy link
Copy Markdown
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Feels like this is getting quite complicated but I did not see anything specifically wrong here. I would like to get @WojtekBoman review here if possible before going ahead

@mountiny mountiny requested a review from WojtekBoman April 9, 2026 00:32
@WojtekBoman
Copy link
Copy Markdown
Contributor

Reviewing it 🕵️

Comment on lines +587 to +610

/**
* Find the navigator state key that directly contains a route with the given key.
* This is needed because SET_PARAMS only searches flat routes arrays, so dispatching
* without `target` fails for routes nested inside split navigators.
*/
function findParentNavigatorKey(routeKey: string, state?: NavigationState): string | undefined {
const navState = state ?? navigationRef.getRootState();
if (!navState?.routes) {
return undefined;
}
for (const route of navState.routes) {
if (route.key === routeKey) {
return navState.key;
}
if (route.state?.routes) {
const found = findParentNavigatorKey(routeKey, route.state as NavigationState);
if (found) {
return found;
}
}
}
return undefined;
}
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.

To me, we can fix this issue without adding this method, let's pass targetKey as a param to Navigation.setParams, it can be read from navigation.getState()?.key in ReportScreen

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.

To me, we can fix this issue without adding this method, let's pass targetKey as a param to Navigation.setParams, it can be read from navigation.getState()?.key in ReportScreen

@MelvinBot let's try that

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.

Done! Removed findParentNavigatorKey entirely and added an optional targetKey parameter to Navigation.setParams instead. In LinkedActionNotFoundGuard, the navigator key is now read via useNavigation().getState()?.key and passed directly. Also updated cleanStaleBackToParam to track navigator keys during its walk and pass them through. All 146 navigation tests pass.

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.

Actually, I am not sure this will work.
navigation.getState()?.key - won't this get key from current page?

This entire complex code was added because of this bug.

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.

And it's possible that the same report screen is multiply stacked in the navigation. (on mobile)
If reportActionID was removed while in other navigation route, will this remove all reportActionIDs in multiple report screens?

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.

@WojtekBoman can you check this out please?

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.

Checking it!

Copy link
Copy Markdown
Contributor

@WojtekBoman WojtekBoman Apr 10, 2026

Choose a reason for hiding this comment

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

@aimane-chnaif If it's called only from ReportScreen it should return the key of the reports screen parent route. I believe it should work, but if the bug is still reproducible with reading it this way, we can add this method findParentNavigatorKey.

However I would suggest to:

  • add it to navigation helpers package and not export it from Navigation.ts
  • don't call this method directly from setParams, if we want to use this method, let's call it before setParams and pass targetKey to setParams.

Additionally, please let's cleanup Navigation.cleanStaleBackToParam. I think we should keep it close to ReportScreen, remove it from Navigation.ts and definitely rename it as this method is mainly used for report params and function name does not indicate it's a method specific for report params.

// When a routeKey is provided, find its parent navigator and set `target` so the
// action is delivered directly to that navigator. Without this, SET_PARAMS fails
// for routes nested inside split navigators (e.g. when a modal is focused).
const navigatorKey = routeKey ? findParentNavigatorKey(routeKey) : undefined;
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.

Don't read it using an additional function, just add a new optional param to this method called targetKey

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.

Done in the latest commit — setParams now accepts an optional targetKey as its third parameter.

Instead of auto-discovering the parent navigator by walking the state
tree, accept an optional targetKey parameter on Navigation.setParams.
Callers read the navigator key via navigation.getState()?.key and pass
it directly. This is simpler and avoids the tree-walk helper entirely.

Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team as a code owner April 9, 2026 10:45
@melvin-bot melvin-bot bot requested a review from aimane-chnaif April 9, 2026 10:45
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Apr 9, 2026

@aimane-chnaif 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 April 9, 2026 10:45
// Also strip the stale reportActionID from any `backTo` params on sibling routes
// (e.g. the IOU report screen that was navigated to FROM this deep link).
if (reportIDFromRoute) {
Navigation.cleanStaleBackToParam(reportIDFromRoute, reportActionIDFromRoute);
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.

I think we know routes which should be cleaned, so maybe let's just find this specific route and clean it's backTo, instead of going through the whole state

@mountiny
Copy link
Copy Markdown
Contributor

mountiny commented Apr 9, 2026

@aimane-chnaif did you test if its working?

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.

4 participants