Skip to content

Fix Profile back-button loop after copiloting into an agent#94239

Draft
abzokhattab wants to merge 1 commit into
Expensify:mainfrom
abzokhattab:abzokhattab-fix-agent-profile-back-loop
Draft

Fix Profile back-button loop after copiloting into an agent#94239
abzokhattab wants to merge 1 commit into
Expensify:mainfrom
abzokhattab:abzokhattab-fix-agent-profile-back-loop

Conversation

@abzokhattab

Copy link
Copy Markdown
Contributor

Explanation of Change

This re-lands the every-focus agent redirect from #93683 (reverted as a deploy blocker) and fixes the regression it introduced (#94088).

Two competing bugs must be solved at once:

Fix: Keep the every-focus useFocusEffect redirect, but pass forceReplace: true so the redirect REPLACEs the stale guarded central-pane route instead of pushing on top of it:

[Account] [Agents (guarded)]  --REPLACE-->  [Account] [Profile]

Back from Profile now pops to the unguarded SCREENS.SETTINGS.ROOT (Account sidebar). forceReplace sets action.type = REPLACE in linkTo, and getMinimalAction preserves that type while drilling into the SettingsSplitNavigator, so the REPLACE lands on the central-pane entry while the persistent SETTINGS.ROOT sidebar stays in place.

Fixed Issues

$ #94088

Tests

  1. Sign in as an owner who has created at least one agent.
  2. Go to Account > Agents > select an agent > tap "Copilot into account".
  3. Tap the back button on the Profile page.
  4. Verify you land on the Account page (not Profile, and not a Profile ⇄ Profile loop).
  5. Navigate back onto a guarded screen (e.g. Agents) as the agent and verify you are bounced to Profile with no blank pane and no "Hmm... it's not here".
  6. Switch back to the owner account via the bottom account-switch drawer and verify it lands on Home/Inbox.
  • Verify that no errors appear in the JS console

Unit test tests/unit/withAgentAccessDenied.test.tsx updated and passing (asserts the {forceReplace: true} redirect, plus the useFocusEffect mock).

Offline tests

N/A — account switching is blocked while offline.

QA Steps

  1. Sign in as an owner who has created at least one agent.
  2. Go to Account > Agents > select an agent > tap "Copilot into account".
  3. Tap the back button on the Profile page → must land on Account.
  4. Regression: navigating back onto a guarded screen as an agent bounces to Profile with no blank pane; switching back to the owner lands on Home.
  • 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 unit test coverage for the change

Redirect agents off guarded routes on every focus (fixes blank pane when
navigating back onto a screen the split navigator keeps mounted) and use
forceReplace so the stale guarded central-pane route is consumed instead of
pushing Profile on top of it, which trapped users in a Profile <-> Profile
loop on back navigation.
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.

1 participant