Skip to content

Commit

Permalink
Merge pull request Expensify#51839 from nkdengineer/fix/51750
Browse files Browse the repository at this point in the history
fix: Skip onboarding screen with company size if signupQualifier is VSB
  • Loading branch information
carlosmiceli authored Nov 12, 2024
2 parents 2fb666e + d979c4a commit 9b62f29
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/libs/actions/Welcome/OnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function getOnboardingInitialPath(): string {

if (isVsb) {
Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`;
Onyx.set(ONYXKEYS.ONBOARDING_COMPANY_SIZE, CONST.ONBOARDING_COMPANY_SIZE.MICRO);
return `/${ROUTES.ONBOARDING_ACCOUNTING.route}`;
}
const isIndividual = onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.INDIVIDUAL;
if (isIndividual) {
Expand Down
27 changes: 22 additions & 5 deletions src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useMemo, useState} from 'react';
import React, {useEffect, useMemo, useState} from 'react';
import {InteractionManager} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import FormHelpMessage from '@components/FormHelpMessage';
Expand All @@ -20,6 +21,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import navigateAfterOnboarding from '@libs/navigateAfterOnboarding';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import * as Policy from '@userActions/Policy/Policy';
import * as Report from '@userActions/Report';
import * as Welcome from '@userActions/Welcome';
import CONST from '@src/CONST';
Expand All @@ -41,6 +43,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
// We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
Expand All @@ -50,6 +53,19 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding

const [userReportedIntegration, setUserReportedIntegration] = useState<OnboardingAccountingType | undefined>(undefined);
const [error, setError] = useState('');
const isVsb = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;

// If the signupQualifier is VSB, the company size step is skip.
// So we need to create the new workspace in the accounting step
useEffect(() => {
if (!isVsb || !!onboardingPolicyID) {
return;
}

const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
Welcome.setOnboardingPolicyID(policyID);
}, [isVsb, onboardingPolicyID]);

const accountingOptions: OnboardingListItem[] = useMemo(() => {
const policyAccountingOptions = Object.values(CONST.POLICY.CONNECTIONS.NAME)
Expand Down Expand Up @@ -147,10 +163,11 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
onboardingCompanySize,
userReportedIntegration,
);

Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();

// Avoid creating new WS because onboardingPolicyID is cleared before unmounting
InteractionManager.runAfterInteractions(() => {
Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();
});
navigateAfterOnboarding(isSmallScreenWidth, shouldUseNarrowLayout, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID, route.params?.backTo);
}}
pressOnEnter
Expand Down

0 comments on commit 9b62f29

Please sign in to comment.