From 563e5bf5d8ad3dd085dca38e74e2ea81dde164a9 Mon Sep 17 00:00:00 2001 From: "dmkt9 (via MelvinBot)" Date: Wed, 30 Sep 2026 07:32:58 +0000 Subject: [PATCH] Allow opening workspace confirmation from any screen so the FAB works on Account and Insights tabs Co-authored-by: dmkt9 --- src/ROUTES.ts | 2 +- .../workspaceConfirmationEntryScreensTest.ts | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index d860d3a76e6b..afc1163cab4c 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -234,7 +234,7 @@ const DYNAMIC_ROUTES = { }, WORKSPACE_CONFIRMATION: { path: 'workspace/confirmation', - entryScreens: [SCREENS.HOME, SCREENS.INBOX, SCREENS.REPORT, SCREENS.SEARCH.ROOT, SCREENS.WORKSPACES_LIST, SCREENS.SETTINGS.ROOT], + entryScreens: ['*'], }, WORKSPACE_CONFIRMATION_CURRENCY: { path: 'currency', diff --git a/tests/navigation/workspaceConfirmationEntryScreensTest.ts b/tests/navigation/workspaceConfirmationEntryScreensTest.ts index ff6600ccf81c..ff6730ece7ea 100644 --- a/tests/navigation/workspaceConfirmationEntryScreensTest.ts +++ b/tests/navigation/workspaceConfirmationEntryScreensTest.ts @@ -1,6 +1,44 @@ -import {DYNAMIC_ROUTES} from '@src/ROUTES'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; +import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath'; + +import CONST from '@src/CONST'; +import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; +import type {NavigationState, PartialState} from '@react-navigation/native'; + +function getFocusedRouteName(state: PartialState): string | undefined { + let current: PartialState | undefined = state; + let name: string | undefined; + + while (current?.routes) { + const nextRoute = current.routes.at(current.index ?? current.routes.length - 1); + name = nextRoute?.name; + current = nextRoute?.state; + } + + return name; +} + +/** + * The FAB "New workspace" item opens the confirmation route appended to whichever screen is active, + * and the FAB is reachable from every tab. A host missing from `entryScreens` fails validation in + * getStateFromPath, so the user lands on Not Found instead of the confirmation page. + */ +describe('WORKSPACE_CONFIRMATION', () => { + it.each([ + ['the Account tab profile page', ROUTES.SETTINGS_PROFILE.route], + ['the Insights tab', ROUTES.INSIGHTS.getRoute(CONST.INSIGHTS.DASHBOARD.SPEND)], + ])('opens the confirmation page from %s', (_label, basePath) => { + // Given the user is on a tab outside the original entry screens (the wide Account tab lands on the profile page) + // When the FAB builds the confirmation route on top of that page + const url = createDynamicRoute(DYNAMIC_ROUTES.WORKSPACE_CONFIRMATION.path, basePath); + + // Then the path resolves to the confirmation screen instead of Not Found + expect(getFocusedRouteName(getStateFromPath(url))).toBe(SCREENS.WORKSPACE_CONFIRMATION.DYNAMIC_ROOT); + }); +}); + /** * The confirm workspace form always renders the currency row, and that row opens the `currency` * dynamic route appended to whichever screen is hosting the form. A host missing from