Skip to content

Commit 37bf849

Browse files
authored
Merge pull request Expensify#85251 from Krishna2323/krishna2323/issue/66417-2.7
Thread betas through `buildPolicyData` and `openReportFromDeepLink` to `prepareOnboardingOnyxData`.
2 parents 9f8fb9f + 9143e99 commit 37bf849

14 files changed

Lines changed: 77 additions & 6 deletions

File tree

src/DeepLinkHandler.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
3030
const [, sessionMetadata] = useOnyx(ONYXKEYS.SESSION);
3131
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
3232
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
33+
const [betas] = useOnyx(ONYXKEYS.BETAS);
3334
const isAuthenticated = useIsAuthenticated();
3435

3536
useEffect(() => {
@@ -47,7 +48,7 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
4748
if (introSelected === undefined) {
4849
Log.info('[Deep link] introSelected is undefined when processing initial URL', false, {url});
4950
}
50-
openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected);
51+
openReportFromDeepLink(url, allReports, isAuthenticated, conciergeReportID, introSelected, betas);
5152
} else {
5253
Report.doneCheckingPublicRoom();
5354
}
@@ -64,14 +65,14 @@ function DeepLinkHandler({onInitialUrl}: DeepLinkHandlerProps) {
6465
Log.info('[Deep link] introSelected is undefined when processing URL change', false, {url: state.url});
6566
}
6667
const isCurrentlyAuthenticated = hasAuthToken();
67-
openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected);
68+
openReportFromDeepLink(state.url, allReports, isCurrentlyAuthenticated, conciergeReportID, introSelected, betas);
6869
});
6970

7071
return () => {
7172
linkingChangeListener.current?.remove();
7273
};
7374
// eslint-disable-next-line react-hooks/exhaustive-deps -- we only want this effect to re-run when conciergeReportID changes
74-
}, [sessionMetadata?.status, conciergeReportID, introSelected]);
75+
}, [sessionMetadata?.status, conciergeReportID, introSelected, betas]);
7576

7677
return null;
7778
}

src/components/SettlementButton/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ function SettlementButton({
357357
activePolicyID,
358358
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
359359
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
360+
betas,
360361
isSelfTourViewed,
361362
}).policyID;
362363
};

src/libs/actions/App.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ type CreateWorkspaceWithPolicyDraftParams = {
567567
currentUserEmailParam: string;
568568
shouldCreateControlPolicy?: boolean;
569569
type?: PolicyType;
570+
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
571+
betas?: OnyxEntry<OnyxTypes.Beta[]>;
570572
};
571573

572574
/**
@@ -591,6 +593,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
591593
shouldCreateControlPolicy,
592594
type,
593595
isSelfTourViewed,
596+
betas,
594597
} = params;
595598

596599
const policyIDWithDefault = policyID || generatePolicyID();
@@ -617,6 +620,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(params: CreateWorkspaceWi
617620
shouldCreateControlPolicy,
618621
type,
619622
isSelfTourViewed,
623+
betas,
620624
});
621625
Navigation.navigate(routeToNavigate, {forceReplace: !transitionFromOldDot});
622626
});
@@ -637,6 +641,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa
637641
currentUserEmailParam,
638642
shouldCreateControlPolicy,
639643
isSelfTourViewed,
644+
betas,
640645
} = params;
641646

642647
createDraftInitialWorkspace(introSelected, policyOwnerEmail, policyName, policyID, makeMeAdmin, currency, file);
@@ -655,6 +660,7 @@ function createWorkspaceWithPolicyDraft(params: CreateWorkspaceWithPolicyDraftPa
655660
allReportsParam: allReports,
656661
shouldCreateControlPolicy,
657662
isSelfTourViewed,
663+
betas,
658664
});
659665
}
660666

@@ -674,6 +680,8 @@ type SavePolicyDraftByNewWorkspaceParams = {
674680
allReportsParam: OnyxCollection<OnyxTypes.Report>;
675681
shouldCreateControlPolicy?: boolean;
676682
type?: PolicyType;
683+
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
684+
betas?: OnyxEntry<OnyxTypes.Beta[]>;
677685
};
678686

679687
/**
@@ -695,6 +703,7 @@ function savePolicyDraftByNewWorkspace({
695703
shouldCreateControlPolicy,
696704
type,
697705
isSelfTourViewed,
706+
betas,
698707
}: SavePolicyDraftByNewWorkspaceParams) {
699708
createWorkspace({
700709
policyOwnerEmail,
@@ -713,6 +722,7 @@ function savePolicyDraftByNewWorkspace({
713722
shouldCreateControlPolicy,
714723
type,
715724
isSelfTourViewed,
725+
betas,
716726
});
717727
}
718728

src/libs/actions/IOU/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,6 +3831,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T
38313831
currentUserEmailParam,
38323832
introSelected,
38333833
activePolicyID,
3834+
betas,
38343835
isSelfTourViewed,
38353836
});
38363837
createdWorkspaceParams = workspaceData.params;
@@ -9331,6 +9332,7 @@ function getPayMoneyRequestParams({
93319332
introSelected,
93329333
activePolicyID: activePolicy?.id,
93339334
companySize: introSelected?.companySize as OnboardingCompanySize,
9335+
betas,
93349336
isSelfTourViewed,
93359337
});
93369338
const {adminsChatReportID, adminsCreatedReportActionID, expenseChatReportID, expenseCreatedReportActionID, customUnitRateID, customUnitID, ownerEmail, policyName} = params;

src/libs/actions/Link.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
2828
import type {Route} from '@src/ROUTES';
2929
import ROUTES from '@src/ROUTES';
3030
import SCREENS from '@src/SCREENS';
31-
import type {IntroSelected, Report} from '@src/types/onyx';
31+
import type {Beta, IntroSelected, Report} from '@src/types/onyx';
3232
import {doneCheckingPublicRoom, navigateToConciergeChat, openReport} from './Report';
3333
import {canAnonymousUserAccessRoute, isAnonymousUser, signOutAndRedirectToSignIn, waitForUserSignIn} from './Session';
3434
import {setOnboardingErrorMessage} from './Welcome';
@@ -232,7 +232,14 @@ function openLink(href: string, environmentURL: string, isAttachment = false) {
232232
openExternalLink(href);
233233
}
234234

235-
function openReportFromDeepLink(url: string, reports: OnyxCollection<Report>, isAuthenticated: boolean, conciergeReportID: string | undefined, introSelected: OnyxEntry<IntroSelected>) {
235+
function openReportFromDeepLink(
236+
url: string,
237+
reports: OnyxCollection<Report>,
238+
isAuthenticated: boolean,
239+
conciergeReportID: string | undefined,
240+
introSelected: OnyxEntry<IntroSelected>,
241+
betas: OnyxEntry<Beta[]>,
242+
) {
236243
const reportID = getReportIDFromLink(url);
237244

238245
if (reportID && !isAuthenticated) {
@@ -244,7 +251,7 @@ function openReportFromDeepLink(url: string, reports: OnyxCollection<Report>, is
244251
});
245252

246253
// 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
247-
openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true});
254+
openReport({reportID, introSelected, parentReportActionID: '0', isFromDeepLink: true, betas});
248255

249256
// Show the sign-in page if the app is offline
250257
if (networkStatus === CONST.NETWORK.NETWORK_STATUS.OFFLINE) {

src/libs/actions/Policy/Policy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ type BuildPolicyDataOptions = {
197197
type?: typeof CONST.POLICY.TYPE.TEAM | typeof CONST.POLICY.TYPE.CORPORATE;
198198
// TODO: Make it required once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
199199
isSelfTourViewed?: boolean;
200+
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
201+
betas?: OnyxEntry<Beta[]>;
200202
};
201203

202204
// TODO: Remove this type once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
@@ -2379,6 +2381,7 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData<BuildPolicyD
23792381
shouldCreateControlPolicy = false,
23802382
type,
23812383
isSelfTourViewed,
2384+
betas,
23822385
} = options;
23832386
const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail);
23842387

@@ -2844,6 +2847,7 @@ function buildPolicyData(options: BuildPolicyDataOptions): OnyxData<BuildPolicyD
28442847
onboardingPurposeSelected,
28452848
companySize: companySize ?? (introSelected?.companySize as OnboardingCompanySize),
28462849
isSelfTourViewed,
2850+
betas,
28472851
});
28482852
if (!onboardingData) {
28492853
return {successData, optimisticData, failureData, params};

src/pages/OnboardingInterestedFeatures/BaseOnboardingInterestedFeatures.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ function BaseOnboardingInterestedFeatures({shouldUseNativeStyles}: BaseOnboardin
203203
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
204204
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
205205
shouldAddGuideWelcomeMessage: false,
206+
betas,
206207
isSelfTourViewed,
207208
})
208209
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};

src/pages/OnboardingWorkspaceConfirmation/BaseOnboardingWorkspaceConfirmation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
3535
const styles = useThemeStyles();
3636
const {translate} = useLocalize();
3737
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
38+
const [betas] = useOnyx(ONYXKEYS.BETAS);
3839
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
3940
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
4041
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
@@ -84,6 +85,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
8485
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
8586
shouldAddGuideWelcomeMessage: false,
8687
onboardingPurposeSelected,
88+
betas,
8789
isSelfTourViewed,
8890
})
8991
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};
@@ -104,6 +106,7 @@ function BaseOnboardingWorkspaceConfirmation({shouldUseNativeStyles}: BaseOnboar
104106
currentUserPersonalDetails.accountID,
105107
currentUserPersonalDetails.email,
106108
introSelected,
109+
betas,
107110
isSelfTourViewed,
108111
],
109112
);

src/pages/OnboardingWorkspaceOptional/BaseOnboardingWorkspaceOptional.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function BaseOnboardingWorkspaceOptional({shouldUseNativeStyles}: BaseOnboarding
169169
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
170170
shouldAddGuideWelcomeMessage: false,
171171
onboardingPurposeSelected,
172+
betas,
172173
isSelfTourViewed,
173174
})
174175
: {adminsChatReportID: onboardingAdminsChatReportID, policyID: onboardingPolicyID};
@@ -189,6 +190,7 @@ function BaseOnboardingWorkspaceOptional({shouldUseNativeStyles}: BaseOnboarding
189190
currentUserPersonalDetails.email,
190191
introSelected,
191192
activePolicyID,
193+
betas,
192194
isSelfTourViewed,
193195
completeOnboarding,
194196
]);

src/pages/Travel/WorkspaceConfirmationForTravelPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type WorkspaceConfirmationForTravelPageProps = StackScreenProps<TravelNavigatorP
1717

1818
function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTravelPageProps) {
1919
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
20+
const [betas] = useOnyx(ONYXKEYS.BETAS);
2021
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
2122
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
2223

@@ -38,6 +39,7 @@ function WorkspaceConfirmationForTravelPage({route}: WorkspaceConfirmationForTra
3839
activePolicyID,
3940
currentUserAccountIDParam: currentUserPersonalDetails.accountID,
4041
currentUserEmailParam: currentUserPersonalDetails.email ?? '',
42+
betas,
4143
isSelfTourViewed,
4244
});
4345
goBack();

0 commit comments

Comments
 (0)