Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ function updateOnboardingValuesAndNavigation(onboardingValues: Onboarding | unde
});
}

function setOnboardingMergeAccountStepValue(value: boolean) {
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergeAccountStepCompleted: value});
function setOnboardingMergeAccountStepValue(value: boolean, skipped = false) {
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergeAccountStepCompleted: value, isMergeAccountStepSkipped: skipped});
}
function completeHybridAppOnboarding() {
if (!CONFIG.IS_HYBRID_APP) {
Expand Down
22 changes: 7 additions & 15 deletions src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
return;
}

if (!onboardingValues?.isMergeAccountStepSkipped) {
Navigation.navigate(ROUTES.ONBOARDING_PRIVATE_DOMAIN.getRoute(), {forceReplace: true});
return;
}

Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
}, [onboardingValues?.shouldValidate, isVsb, isSmb, isFocused, onboardingValues?.isMergeAccountStepCompleted]);
}, [onboardingValues?.shouldValidate, isVsb, isSmb, isFocused, onboardingValues?.isMergeAccountStepCompleted, onboardingValues?.isMergeAccountStepSkipped]);

const submitWorkEmail = useCallback((values: FormOnyxValues<typeof ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM>) => {
AddWorkEmail(values[INPUT_IDS.ONBOARDING_WORK_EMAIL]);
Expand Down Expand Up @@ -165,20 +170,7 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
onPress={() => {
setOnboardingErrorMessage('');

setOnboardingMergeAccountStepValue(true);
// Once we skip the private email step, we need to force replace the screen
// so that we don't navigate back on back button press
if (isVsb) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(), {forceReplace: true});
return;
}

if (isSmb) {
Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(), {forceReplace: true});
return;
}

Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
setOnboardingMergeAccountStepValue(true, true);
}}
/>
</OfflineWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ function BaseOnboardingWorkEmailValidation({shouldUseNativeStyles}: BaseOnboardi
return;
}

if (!onboardingValues?.isMergeAccountStepSkipped) {
Navigation.navigate(ROUTES.ONBOARDING_WORKSPACES.getRoute(), {forceReplace: true});

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.

This navigates to ONBOARDING_WORKSPACES with forceReplace: true but without passing the backTo parameter so it caused Add work email - Back button not working on Join workspace screen.
As forceReplace: true is expected, we ended up hiding back button on Join workspace screen.

return;
}

Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
}, [onboardingValues, isVsb, isSmb, isFocused]);

Expand Down Expand Up @@ -131,20 +136,7 @@ function BaseOnboardingWorkEmailValidation({shouldUseNativeStyles}: BaseOnboardi
shouldShowSkipButton
handleSkipButtonPress={() => {
setOnboardingErrorMessage('');
setOnboardingMergeAccountStepValue(true);
// Once we skip the private email step, we need to force replace the screen
// so that we don't navigate back on back button press
if (isVsb) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(), {forceReplace: true});
return;
}

if (isSmb) {
Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(), {forceReplace: true});
return;
}

Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
setOnboardingMergeAccountStepValue(true, true);
}}
isLoading={isValidateCodeFormSubmitting}
validateError={onboardingErrorMessage ? {invalidCodeError: onboardingErrorMessage} : undefined}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type Onboarding = {
/** A Boolean that informs whether the user has completed merge account step */
isMergeAccountStepCompleted?: boolean;

/** A Boolean that informs whether the user has skipped merge account step */
isMergeAccountStepSkipped?: boolean;

/** A Boolean that tells whether the onboarding flow is loading */
isLoading?: boolean;
};
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/WorkEmailOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('OnboardingWorkEmail Page', () => {
await waitForBatchedUpdatesWithAct();
});

it('should navigate to Onboarding purpose page when email is entered but shouldValidate is set to false', async () => {
it('should navigate to Onboarding private domain page when email is entered but shouldValidate is set to false', async () => {
await TestHelper.signInWithTestUser();

await act(async () => {
Expand All @@ -307,7 +307,7 @@ describe('OnboardingWorkEmail Page', () => {
await waitForBatchedUpdatesWithAct();

await waitFor(() => {
expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_PRIVATE_DOMAIN.getRoute(), {forceReplace: true});
});

unmount();
Expand Down Expand Up @@ -485,7 +485,7 @@ describe('OnboardingWorkEmailValidation Page', () => {
await waitForBatchedUpdatesWithAct();
});

it('should navigate to Onboarding purpose page when validate code step is successful and there is no signupQualifier', async () => {
it('should navigate to Onboarding workspaces page when validate code step is successful and there is no signupQualifier', async () => {
await TestHelper.signInWithTestUser();

await act(async () => {
Expand All @@ -507,7 +507,7 @@ describe('OnboardingWorkEmailValidation Page', () => {
await waitForBatchedUpdatesWithAct();

await waitFor(() => {
expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_PURPOSE.getRoute(), {forceReplace: true});
expect(navigate).toHaveBeenCalledWith(ROUTES.ONBOARDING_WORKSPACES.getRoute(), {forceReplace: true});
});

unmount();
Expand Down
Loading