Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles, route}: BaseOnboardingW
{/* This screen normally opens onboarding, so there is nothing to go back to unless the intent list sent us here. */}
<OnboardingHeader
shouldShowBackButton={isJoiningCompanyWorkspace && !isConciergeTaskFlow}
onBackButtonPress={() => Navigation.goBack(ROUTES.ONBOARDING_PURPOSE.getRoute())}
onBackButtonPress={() => Navigation.goBack()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the intent-list fallback after a refresh

When a user selects “Join a workspace” and then refreshes on the work-email URL, deep-link reconstruction leaves only WORK_EMAIL in the onboarding stack. Calling bare goBack() therefore pops the entire onboarding modal instead of returning to the purpose screen, so the visible Back button can take an incomplete-onboarding user out of the flow. Keep ROUTES.ONBOARDING_PURPOSE as the fallback so Back replaces the current route when the purpose screen is no longer in the stack.

Useful? React with 👍 / 👎.

shouldShowCloseButton={isConciergeTaskFlow}
onCloseButtonPress={onboardingValues?.isMergingAccountBlocked ? handleConciergeTaskErrorConfirm : returnToOriginReport}
/>
Expand Down
51 changes: 0 additions & 51 deletions tests/ui/WorkEmailOnboardingNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,6 @@ function OnboardingModalNavigatorWithRealWorkspaces() {
);
}

// Stands in for the intent list; only whether Back lands on it matters.
function OnboardingPurposeStub() {
return <View testID="onboarding-purpose-stub" />;
}

function OnboardingModalNavigatorWithPurpose() {
return (
<OnboardingStack.Navigator screenOptions={{headerShown: false}}>
<OnboardingStack.Screen
name={SCREENS.ONBOARDING.PURPOSE}
component={OnboardingPurposeStub}
/>
<OnboardingStack.Screen
name={SCREENS.ONBOARDING.WORK_EMAIL}
component={OnboardingWorkEmail}
/>
</OnboardingStack.Navigator>
);
}

// The back button is what is under test in the second-visit case, so that one navigator renders the real screen.
function OnboardingModalNavigatorWithWorkspaces() {
return (
Expand Down Expand Up @@ -336,37 +316,6 @@ describe('Onboarding work email navigation', () => {
expect(onboardingValues?.shouldValidate).toBeUndefined();
});

it('should return to the intent list when Back is pressed on the work email screen after a refresh', async () => {
await TestHelper.signInWithTestUser();

await act(async () => {
await Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {
hasCompletedGuidedSetupFlow: false,
});
await Onyx.merge(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.JOIN_WORKSPACE);
await Onyx.merge(ONYXKEYS.ACCOUNT, {validated: false, isFromPublicDomain: true});
});

// Given a refresh rebuilt the stack from the URL, so the intent list is no longer behind the work email screen
renderOnboardingStack([SCREENS.ONBOARDING.WORK_EMAIL], OnboardingModalNavigatorWithPurpose);

await waitForBatchedUpdatesWithAct();

// When the user presses Back
await waitFor(() => {
expect(screen.getByLabelText(TestHelper.translateLocal('common.back'))).toBeOnTheScreen();
});
fireEvent.press(screen.getByLabelText(TestHelper.translateLocal('common.back')));

await waitForBatchedUpdatesWithAct();

// Then the explicit ONBOARDING_PURPOSE fallback replaces the work email screen inside the modal instead of
// popping the whole onboarding modal
await waitFor(() => {
expect(getOnboardingRouteNames()).toEqual([SCREENS.ONBOARDING.PURPOSE]);
});
});

it('should keep Back working on a later visit to Join a workspace after the merge', async () => {
await TestHelper.signInWithTestUser();

Expand Down
Loading