Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - [CRITICAL] Multiple workspaces get created when someone either refreshes the page, or drops off and returns later. #52899

Merged
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import CONST from '@src/CONST';
import type {OnboardingAccounting} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {} from '@src/types/onyx/Bank';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import type {BaseOnboardingAccountingProps} from './types';

type OnboardingListItem = ListItem & {
Expand All @@ -45,7 +46,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
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 [onboardingPolicyID, onboardingPolicyIDResults] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE);
const {canUseDefaultRooms} = usePermissions();
Expand All @@ -58,14 +59,14 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
// 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) {
if (!isVsb || !!onboardingPolicyID || isLoadingOnyxValue(onboardingPolicyIDResults)) {
return;
}

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

const accountingOptions: OnboardingListItem[] = useMemo(() => {
const policyAccountingOptions = Object.values(CONST.POLICY.CONNECTIONS.NAME)
Expand Down
Loading