From cc659e852bfdbf73dfae6ff4159ae8557ec3b2f1 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 14 Oct 2024 13:24:22 -1000 Subject: [PATCH 1/5] Create policy when redirecting past the intent step and the user arrives with a vsb intent in the url --- src/libs/actions/Welcome/OnboardingFlow.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index 3c11f3c440db..e20767b1b013 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -5,6 +5,9 @@ import linkingConfig from '@libs/Navigation/linkingConfig'; import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import type {NavigationPartialRoute, RootStackParamList} from '@libs/Navigation/types'; +import * as Policy from '@userActions/Policy/Policy'; +// eslint-disable-next-line @dword-design/import-alias/prefer-alias +import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -118,9 +121,14 @@ function getOnboardingInitialPath(): string { const isVsb = onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; if (isVsb) { + // Create a workspace for the user if they have selected "Manage my team's expenses" Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.MANAGE_TEAM); + const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); + Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); + Welcome.setOnboardingPolicyID(policyID); return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`; } + const isIndividual = onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.INDIVIDUAL; if (isIndividual) { Onyx.set(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, [CONST.ONBOARDING_CHOICES.PERSONAL_SPEND, CONST.ONBOARDING_CHOICES.EMPLOYER, CONST.ONBOARDING_CHOICES.CHAT_SPLIT]); From fd01c725e49239b7a841e7bb90f153daa104be7f Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 14 Oct 2024 14:22:06 -1000 Subject: [PATCH 2/5] Move the policy creation to the employees step --- src/libs/actions/Welcome/OnboardingFlow.ts | 3 --- .../OnboardingEmployees/BaseOnboardingEmployees.tsx | 9 +++++++++ src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx | 5 ----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index e20767b1b013..aa8f996a4118 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -123,9 +123,6 @@ function getOnboardingInitialPath(): string { if (isVsb) { // Create a workspace for the user if they have selected "Manage my team's expenses" Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.MANAGE_TEAM); - const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); - Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); - Welcome.setOnboardingPolicyID(policyID); return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`; } diff --git a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx index 480ad51f6810..0fcccd723543 100644 --- a/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx +++ b/src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx @@ -12,6 +12,7 @@ import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import * as Policy from '@userActions/Policy/Policy'; import * as Welcome from '@userActions/Welcome'; import * as OnboardingFlow from '@userActions/Welcome/OnboardingFlow'; import CONST from '@src/CONST'; @@ -28,6 +29,7 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE const {translate} = useLocalize(); const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE); const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); + const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID); const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const [selectedCompanySize, setSelectedCompanySize] = useState(onboardingCompanySize); const [error, setError] = useState(''); @@ -61,6 +63,13 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE return; } Welcome.setOnboardingCompanySize(selectedCompanySize); + + if (!onboardingPolicyID) { + const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', Policy.generatePolicyID(), CONST.ONBOARDING_CHOICES.MANAGE_TEAM); + Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); + Welcome.setOnboardingPolicyID(policyID); + } + Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute(route.params?.backTo)); }} pressOnEnter diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 2bdd601b4b59..3cac8da45edf 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -84,11 +84,6 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro Welcome.setOnboardingErrorMessage(''); if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { - if (!onboardingPolicyID) { - const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', generatePolicyID(), choice); - Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); - Welcome.setOnboardingPolicyID(policyID); - } Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(route.params?.backTo)); return; } From bff8e00152754f2bc6fcd12bfddce35f1d3e0db4 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 14 Oct 2024 14:40:32 -1000 Subject: [PATCH 3/5] Remove unneeded stuff --- src/libs/actions/Welcome/OnboardingFlow.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index aa8f996a4118..927898d9c899 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -5,9 +5,6 @@ import linkingConfig from '@libs/Navigation/linkingConfig'; import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import type {NavigationPartialRoute, RootStackParamList} from '@libs/Navigation/types'; -import * as Policy from '@userActions/Policy/Policy'; -// eslint-disable-next-line @dword-design/import-alias/prefer-alias -import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -121,7 +118,6 @@ function getOnboardingInitialPath(): string { const isVsb = onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; if (isVsb) { - // Create a workspace for the user if they have selected "Manage my team's expenses" Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.MANAGE_TEAM); return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`; } From dadf916d85dfec5061b385f9eb031d51ac315401 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 14 Oct 2024 14:42:32 -1000 Subject: [PATCH 4/5] remove other imports not needed --- src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 3cac8da45edf..a59042c572a1 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -20,8 +20,6 @@ import Navigation from '@libs/Navigation/Navigation'; import OnboardingRefManager from '@libs/OnboardingRefManager'; import type {TOnboardingRef} from '@libs/OnboardingRefManager'; import variables from '@styles/variables'; -import * as Policy from '@userActions/Policy/Policy'; -import {generatePolicyID} from '@userActions/Policy/Policy'; import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; import type {OnboardingPurposeType} from '@src/CONST'; @@ -51,7 +49,6 @@ const menuIcons = { function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, route}: BaseOnboardingPurposeProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID); const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); const {windowHeight} = useWindowDimensions(); // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to show offline indicator on small screen only From 94791760dc15a285b5348851e27ee722442b59a5 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 14 Oct 2024 14:42:52 -1000 Subject: [PATCH 5/5] Remove unnecessary newline --- src/libs/actions/Welcome/OnboardingFlow.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index 927898d9c899..3c11f3c440db 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -121,7 +121,6 @@ function getOnboardingInitialPath(): string { Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, CONST.ONBOARDING_CHOICES.MANAGE_TEAM); return `/${ROUTES.ONBOARDING_EMPLOYEES.route}`; } - const isIndividual = onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.INDIVIDUAL; if (isIndividual) { Onyx.set(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, [CONST.ONBOARDING_CHOICES.PERSONAL_SPEND, CONST.ONBOARDING_CHOICES.EMPLOYER, CONST.ONBOARDING_CHOICES.CHAT_SPLIT]);