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
2 changes: 1 addition & 1 deletion src/libs/Navigation/guards/OnboardingGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const OnboardingGuard: NavigationGuard = {
const isSingleEntry = hybridApp?.isSingleNewDotEntry ?? false;
const needsExplanationModal = (CONFIG.IS_HYBRID_APP && tryNewDot?.isHybridAppOnboardingCompleted !== true) ?? false;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const isInvitedOrGroupMember = (!CONFIG.IS_HYBRID_APP && (hasNonPersonalPolicy || wasInvitedToNewDot)) ?? false;
const isInvitedOrGroupMember = (!CONFIG.IS_HYBRID_APP && (hasNonPersonalPolicy || wasInvitedToNewDot) && onboarding?.hasCompletedGuidedSetupFlow !== false) ?? false;

// Redirect completed users who try to navigate to onboarding routes (e.g. via deep link)
// The OnboardingModalNavigator is not mounted when onboarding is complete, so the route would silently fail
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/Navigation/guards/OnboardingGuard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ describe('OnboardingGuard', () => {
expect(result.type).toBe('ALLOW');
});

it('should redirect users with non-personal policies who have not completed onboarding', async () => {
// Given a user who signed up but did not complete onboarding, and was later invited to a workspace
await Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {
hasCompletedGuidedSetupFlow: false,
});
await Onyx.merge(ONYXKEYS.HAS_NON_PERSONAL_POLICY, true);
await Onyx.merge(ONYXKEYS.ACCOUNT, {
isFromPublicDomain: true,
});
await waitForBatchedUpdates();

// When the guard evaluates a navigation action
const result = OnboardingGuard.evaluate(mockState, mockAction, authenticatedContext) as {type: 'REDIRECT'; route: string};

// Then the user should be redirected to onboarding because having a workspace policy should not skip onboarding when the user explicitly started but didn't finish it
expect(result.type).toBe('REDIRECT');
expect(result.route).toContain('onboarding');
});

it('should allow invited users', async () => {
// Given a user who was invited and has already selected their intro choice (SUBMIT), indicating they came through an invitation link
await Onyx.merge(ONYXKEYS.NVP_INTRO_SELECTED, {
Expand Down
Loading