diff --git a/src/DeepLinkHandler.tsx b/src/DeepLinkHandler.tsx index e73386b23f086..4d4010bb744be 100644 --- a/src/DeepLinkHandler.tsx +++ b/src/DeepLinkHandler.tsx @@ -30,6 +30,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) { const [, sessionMetadata] = useOnyx(ONYXKEYS.SESSION); const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const [betas] = useOnyx(ONYXKEYS.BETAS); const isAuthenticated = useIsAuthenticated(); useEffect(() => { @@ -47,7 +48,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) { if (introSelected === undefined) { Log.info('[Deep link] introSelected is undefined when processing initial URL', false, {url}); } - openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected); + openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected, betas); } else { Report.doneCheckingPublicRoom(); } @@ -64,14 +65,14 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) { Log.info('[Deep link] introSelected is undefined when processing URL change', false, {url: state.url}); } const isCurrentlyAuthenticated = hasAuthToken(); - openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected); + openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected, betas); }); return () => { linkingChangeListener.current?.remove(); }; // eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this effect to re-run when conciergeReportID changes - }, [sessionMetadata?.status, conciergeReportID, introSelected]); + }, [sessionMetadata?.status, conciergeReportID, introSelected, betas]); return null; } diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index 0c01b08c9a0ba..f2d876f455d8a 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -357,6 +357,7 @@ function SettlementButton({ activePolicyID, currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.email ?? '', + betas, isSelfTourViewed, }).policyID; }; diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 08285a7a98fd4..de84e0220b6ed 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -567,6 +567,8 @@ type CreateWorkspaceWithPolicyDraftParams = { currentUserEmailParam: string; shouldCreateControlPolicy?: boolean; type?: PolicyType; + // TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417) + betas?: OnyxEntry; }; /** @@ -591,6 +593,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi shouldCreateControlPolicy, type, isSelfTourViewed, + betas, } = params; const policyIDWithDefault = policyID || generatePolicyID(); @@ -617,6 +620,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi shouldCreateControlPolicy, type, isSelfTourViewed, + betas, }); Navigation.navigate(routeToNavigate, {forceReplace: !transitionFromOldDot}); }); @@ -637,6 +641,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa currentUserEmailParam, shouldCreateControlPolicy, isSelfTourViewed, + betas, } = params; createDraftInitialWorkspace(introSelected, policyOwnerEmail, policyName, policyID, makeMeAdmin, currency, file); @@ -655,6 +660,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa allReportsParam: allReports, shouldCreateControlPolicy, isSelfTourViewed, + betas, }); } @@ -674,6 +680,8 @@ type SavePolicyDraftByNewWorkspaceParams = { allReportsParam: OnyxCollection; shouldCreateControlPolicy?: boolean; type?: PolicyType; + // TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417) + betas?: OnyxEntry; }; /** @@ -695,6 +703,7 @@ function savePolicyDraftByNewWorkspace({ shouldCreateControlPolicy, type, isSelfTourViewed, + betas, }: SavePolicyDraftByNewWorkspaceParams) { createWorkspace({ policyOwnerEmail, @@ -713,6 +722,7 @@ function savePolicyDraftByNewWorkspace({ shouldCreateControlPolicy, type, isSelfTourViewed, + betas, }); } diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 99cd0f4e18713..8c5349c970a40 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -3832,6 +3832,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T currentUserEmailParam, introSelected, activePolicyID, + betas, isSelfTourViewed, }); createdWorkspaceParams = workspaceData.params; @@ -9330,6 +9331,7 @@ function getPayMoneyRequestParams({ introSelected, activePolicyID: activePolicy?.id, companySize: introSelected?.companySize as OnboardingCompanySize, + betas, isSelfTourViewed, }); const {adminsChatReportID, adminsCreatedReportActionID, expenseChatReportID, expenseCreatedReportActionID, customUnitRateID, customUnitID, ownerEmail, policyName} = params; diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index b8bd5aad08fcb..8032e26f53836 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -28,7 +28,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import type {IntroSelected, Report} from '@src/types/onyx'; +import type {Beta, IntroSelected, Report} from '@src/types/onyx'; import {doneCheckingPublicRoom, navigateToConciergeChat, openReport} from './Report'; import {canAnonymousUserAccessRoute, isAnonymousUser, signOutAndRedirectToSignIn, waitForUserSignIn} from './Session'; import {setOnboardingErrorMessage} from './Welcome'; @@ -232,7 +232,14 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { openExternalLink(href); } -function openReportFromDeepLink(url: string, reports: OnyxCollection, isAuthenticated: boolean, conciergeReportID: string | undefined, introSelected: OnyxEntry) { +function openReportFromDeepLink( + url: string, + reports: OnyxCollection, + isAuthenticated: boolean, + conciergeReportID: string | undefined, + introSelected: OnyxEntry, + betas: OnyxEntry, +) { const reportID = getReportIDFromLink(url); if (reportID && !isAuthenticated) { @@ -244,7 +251,7 @@ function openReportFromDeepLink(url: string, reports: OnyxCollection, is }); // Call the OpenReport command to check in the server if it's a public room. If so, we'll open it as an anonymous user - openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true}); + openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true, betas}); // Show the sign-in page if the app is offline if (networkStatus === CONST.NETWORK.NETWORK_STATUS.OFFLINE) { diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 87a02f757be2b..8f8b4460f0eaa 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -197,6 +197,8 @@ type BuildPolicyDataOptions = { type?: typeof CONST.POLICY.TYPE.TEAM | typeof CONST.POLICY.TYPE.CORPORATE; // TODO: Make it required once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424 isSelfTourViewed?: boolean; + // TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417) + betas?: OnyxEntry; }; // TODO: Remove this type once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424 @@ -2388,6 +2390,7 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData { expect(policy?.approvalMode).toBe(CONST.POLICY.APPROVAL_MODE.BASIC); }); + it('creates a new workspace when betas are explicitly passed', async () => { + const policyID = Policy.generatePolicyID(); + Policy.createWorkspace({ + policyOwnerEmail: ESH_EMAIL, + makeMeAdmin: true, + policyName: WORKSPACE_NAME, + policyID, + engagementChoice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM, + introSelected: {choice: CONST.ONBOARDING_CHOICES.MANAGE_TEAM}, + currentUserAccountIDParam: ESH_ACCOUNT_ID, + currentUserEmailParam: ESH_EMAIL, + isSelfTourViewed: false, + betas: [CONST.BETAS.SUGGESTED_FOLLOWUPS], + }); + await waitForBatchedUpdates(); + + const policy: OnyxEntry | OnyxCollection = await new Promise((resolve) => { + const connection = Onyx.connect({ + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + callback: (workspace) => { + Onyx.disconnect(connection); + resolve(workspace); + }, + }); + }); + + expect(policy?.id).toBe(policyID); + expect(policy?.name).toBe(WORKSPACE_NAME); + expect(policy?.approvalMode).toBe(CONST.POLICY.APPROVAL_MODE.BASIC); + }); + it('creates a new workspace with OPTIONAL approval mode if the introSelected is TRACK_WORKSPACE', async () => { const policyID = Policy.generatePolicyID(); // When a new workspace is created with introSelected set to TRACK_WORKSPACE