Skip to content

Commit 5635046

Browse files
authored
Merge pull request #86706 from Krishna2323/krishna2323/issue/66417-2.13
Remove Onyx.connectWithoutView for ONYXKEYS.BETAS in ReportUtils and make betas required across all callers.
2 parents 6fb2f69 + 760f0a8 commit 5635046

16 files changed

Lines changed: 124 additions & 43 deletions

src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function AuthScreensInitHandler() {
138138
App.reconnectApp(initialLastUpdateIDAppliedToClient);
139139
}
140140

141-
App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID, isSelfTourViewed, hasActiveAdminPolicies);
141+
App.setUpPoliciesAndNavigate(session, introSelected, activePolicyID, isSelfTourViewed, betas, hasActiveAdminPolicies);
142142

143143
Download.clearDownloads();
144144

src/libs/ReportUtils.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,12 +1029,6 @@ getEnvironment().then((env) => {
10291029
environment = env;
10301030
});
10311031

1032-
let allBetas: OnyxEntry<Beta[]>;
1033-
Onyx.connectWithoutView({
1034-
key: ONYXKEYS.BETAS,
1035-
callback: (value) => (allBetas = value),
1036-
});
1037-
10381032
// This cache is used to save parse result of report action html message into text
10391033
// to prevent unnecessary parsing when the report action is not changed/modified.
10401034
// Example case: when we need to get a report name of a thread which is dependent on a report action message.
@@ -11758,7 +11752,7 @@ type PrepareOnboardingOnyxDataParams = {
1175811752
isInvitedAccountant?: boolean;
1175911753
onboardingPurposeSelected?: OnboardingPurpose;
1176011754
isSelfTourViewed?: boolean;
11761-
betas?: OnyxEntry<Beta[]>;
11755+
betas: OnyxEntry<Beta[]>;
1176211756
};
1176311757

1176411758
function getBespokeWelcomeMessage(companySize: OnboardingCompanySize | undefined, userReportedIntegration?: OnboardingAccounting): string {
@@ -11828,7 +11822,7 @@ function prepareOnboardingOnyxData({
1182811822
// Only the MANAGE_TEAM onboarding action uses the #admins room (with a guide); TRACK_WORKSPACE uses Concierge. Excludes emails that have a '+'.
1182911823
const shouldPostTasksInAdminsRoom = isPostingTasksInAdminsRoom(engagementChoice);
1183011824
// When posting to admins room and the user is in the suggestedFollowups beta, we skip tasks in favor of backend-generated followups.
11831-
const shouldUseFollowupsInsteadOfTasks = shouldPostTasksInAdminsRoom && Permissions.isBetaEnabled(CONST.BETAS.SUGGESTED_FOLLOWUPS, betas ?? allBetas, betaConfiguration);
11825+
const shouldUseFollowupsInsteadOfTasks = shouldPostTasksInAdminsRoom && Permissions.isBetaEnabled(CONST.BETAS.SUGGESTED_FOLLOWUPS, betas, betaConfiguration);
1183211826
const adminsChatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${adminsChatReportID}`];
1183311827
const targetChatReport = shouldPostTasksInAdminsRoom
1183411828
? (adminsChatReport ?? {reportID: adminsChatReportID, policyID: onboardingPolicyID})

src/libs/actions/App.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ type CreateWorkspaceWithPolicyDraftParams = {
568568
currentUserEmailParam: string;
569569
shouldCreateControlPolicy?: boolean;
570570
type?: PolicyType;
571-
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
572-
betas?: OnyxEntry<OnyxTypes.Beta[]>;
571+
betas: OnyxEntry<OnyxTypes.Beta[]>;
573572
hasActiveAdminPolicies: boolean;
574573
};
575574

@@ -686,8 +685,7 @@ type SavePolicyDraftByNewWorkspaceParams = {
686685
allReportsParam: OnyxCollection<OnyxTypes.Report>;
687686
shouldCreateControlPolicy?: boolean;
688687
type?: PolicyType;
689-
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
690-
betas?: OnyxEntry<OnyxTypes.Beta[]>;
688+
betas: OnyxEntry<OnyxTypes.Beta[]>;
691689
hasActiveAdminPolicies: boolean;
692690
};
693691

@@ -755,6 +753,7 @@ function setUpPoliciesAndNavigate(
755753
introSelected: OnyxEntry<OnyxTypes.IntroSelected>,
756754
activePolicyID: string | undefined,
757755
isSelfTourViewed: boolean | undefined,
756+
betas: OnyxEntry<OnyxTypes.Beta[]>,
758757
hasActiveAdminPolicies: boolean,
759758
) {
760759
const currentUrl = getCurrentUrl();
@@ -787,6 +786,7 @@ function setUpPoliciesAndNavigate(
787786
currentUserAccountIDParam: currentSessionData.accountID ?? CONST.DEFAULT_NUMBER_ID,
788787
currentUserEmailParam: currentSessionData.email ?? '',
789788
isSelfTourViewed,
789+
betas,
790790
hasActiveAdminPolicies,
791791
});
792792
return;

src/libs/actions/Policy/Policy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ type BuildPolicyDataOptions = {
208208
type?: typeof CONST.POLICY.TYPE.TEAM | typeof CONST.POLICY.TYPE.CORPORATE;
209209
// TODO: Make it required once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424
210210
isSelfTourViewed?: boolean;
211-
// TODO: Remove optional (?) once allBetas Onyx.connect is removed (https://github.com/Expensify/App/issues/66417)
212-
betas?: OnyxEntry<Beta[]>;
211+
betas: OnyxEntry<Beta[]>;
213212
};
214213

215214
// TODO: Remove this type once we complete refactoring the buildPolicyData function to use isSelfTourViewed. Refactor issue: https://github.com/Expensify/App/issues/66424

src/libs/actions/Report/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ type OpenReportActionParams = {
322322
/** Whether the user has seen the self tour */
323323
// TODO: This will be required eventually. Refactor issue: https://github.com/Expensify/App/issues/66424
324324
isSelfTourViewed?: boolean;
325-
/** Beta features list. TODO: Remove optional (?) once buildPolicyData is updated (https://github.com/Expensify/App/issues/66417) */
326-
betas?: OnyxEntry<Beta[]>;
325+
326+
/** Beta features list */
327+
betas: OnyxEntry<Beta[]>;
327328
};
328329

329330
type PregeneratedResponseParams = {
@@ -1661,9 +1662,8 @@ function createGroupChat(
16611662
currentUserLogin: string,
16621663
introSelected: OnyxEntry<IntroSelected>,
16631664
isSelfTourViewed: boolean | undefined,
1665+
betas: OnyxEntry<Beta[]>,
16641666
avatar?: File | CustomRNImageManipulatorResult,
1665-
// TODO: Remove optional (?) once buildPolicyData is updated (https://github.com/Expensify/App/issues/66417)
1666-
betas?: OnyxEntry<Beta[]>,
16671667
) {
16681668
const optimisticReport = {
16691669
reportName: CONST.REPORT.DEFAULT_REPORT_NAME,
@@ -2003,16 +2003,15 @@ function navigateToAndCreateGroupChat(
20032003
optimisticReportID: string,
20042004
introSelected: OnyxEntry<IntroSelected>,
20052005
isSelfTourViewed: boolean | undefined,
2006+
betas: OnyxEntry<Beta[]>,
20062007
avatarUri?: string,
20072008
avatarFile?: File | CustomRNImageManipulatorResult | undefined,
2008-
// TODO: Remove optional (?) once buildPolicyData is updated (https://github.com/Expensify/App/issues/66417)
2009-
betas?: OnyxEntry<Beta[]>,
20102009
) {
20112010
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins(userLogins);
20122011

20132012
// If we are creating a group chat then participantAccountIDs is expected to contain currentUserAccountID
20142013
const newChat = buildOptimisticGroupChatReport(participantAccountIDs, reportName, avatarUri ?? '', optimisticReportID, CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
2015-
createGroupChat(newChat.reportID, userLogins, newChat, currentUserLogin, introSelected, isSelfTourViewed, avatarFile, betas);
2014+
createGroupChat(newChat.reportID, userLogins, newChat, currentUserLogin, introSelected, isSelfTourViewed, betas, avatarFile);
20162015

20172016
navigateToReport(newChat.reportID);
20182017
}

src/pages/NewChatConfirmPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ function NewChatConfirmPage() {
111111
optimisticReportID.current,
112112
introSelected,
113113
isSelfTourViewed,
114+
betas,
114115
newGroupDraft.avatarUri ?? '',
115116
avatarFile,
116-
betas,
117117
);
118118
}, [newGroupDraft, avatarFile, personalData.login, introSelected, betas, isSelfTourViewed]);
119119

src/pages/inbox/report/PureReportActionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ type PureReportActionItemProps = {
277277
introSelected?: OnyxEntry<OnyxTypes.IntroSelected>;
278278

279279
/** Beta features list */
280-
betas?: OnyxEntry<OnyxTypes.Beta[]>;
280+
betas: OnyxEntry<OnyxTypes.Beta[]>;
281281

282282
/** All transaction draft IDs */
283283
draftTransactionIDs: string[] | undefined;

src/pages/inbox/report/ReportActionItem.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ import PureReportActionItem from './PureReportActionItem';
4040

4141
type ReportActionItemProps = Omit<
4242
PureReportActionItemProps,
43-
'taskReport' | 'linkedReport' | 'iouReportOfLinkedReport' | 'currentUserAccountID' | 'currentUserEmail' | 'personalPolicyID' | 'draftTransactionIDs' | 'userBillingGracePeriodEnds'
43+
| 'taskReport'
44+
| 'linkedReport'
45+
| 'iouReportOfLinkedReport'
46+
| 'currentUserAccountID'
47+
| 'currentUserEmail'
48+
| 'personalPolicyID'
49+
| 'draftTransactionIDs'
50+
| 'userBillingGracePeriodEnds'
51+
| 'betas'
4452
> & {
4553
/** Whether to show the draft message or not */
4654
shouldShowDraftMessage?: boolean;

tests/actions/IOUTest.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6945,6 +6945,7 @@ describe('actions/IOU', () => {
69456945
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
69466946
currentUserEmailParam: CARLOS_EMAIL,
69476947
isSelfTourViewed: false,
6948+
betas: undefined,
69486949
hasActiveAdminPolicies: false,
69496950
});
69506951
return waitForBatchedUpdates();
@@ -7105,6 +7106,7 @@ describe('actions/IOU', () => {
71057106
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
71067107
currentUserEmailParam: CARLOS_EMAIL,
71077108
isSelfTourViewed: false,
7109+
betas: undefined,
71087110
hasActiveAdminPolicies: false,
71097111
});
71107112
return waitForBatchedUpdates();
@@ -7676,6 +7678,7 @@ describe('actions/IOU', () => {
76767678
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
76777679
currentUserEmailParam: CARLOS_EMAIL,
76787680
isSelfTourViewed: false,
7681+
betas: undefined,
76797682
hasActiveAdminPolicies: false,
76807683
});
76817684
return waitForBatchedUpdates();
@@ -8179,6 +8182,7 @@ describe('actions/IOU', () => {
81798182
openReport({
81808183
reportID: thread.reportID,
81818184
introSelected: TEST_INTRO_SELECTED,
8185+
betas: undefined,
81828186
participantLoginList: userLogins,
81838187
newReportObject: thread,
81848188
parentReportActionID: createIOUAction?.reportActionID,
@@ -8278,6 +8282,7 @@ describe('actions/IOU', () => {
82788282
openReport({
82798283
reportID: thread.reportID,
82808284
introSelected: TEST_INTRO_SELECTED,
8285+
betas: undefined,
82818286
participantLoginList: userLogins,
82828287
newReportObject: thread,
82838288
parentReportActionID: createIOUAction?.reportActionID,
@@ -8400,6 +8405,7 @@ describe('actions/IOU', () => {
84008405
openReport({
84018406
reportID: thread.reportID,
84028407
introSelected: TEST_INTRO_SELECTED,
8408+
betas: undefined,
84038409
participantLoginList: userLogins,
84048410
newReportObject: thread,
84058411
parentReportActionID: createIOUAction?.reportActionID,
@@ -8536,6 +8542,7 @@ describe('actions/IOU', () => {
85368542
openReport({
85378543
reportID: thread.reportID,
85388544
introSelected: TEST_INTRO_SELECTED,
8545+
betas: undefined,
85398546
participantLoginList: userLogins,
85408547
newReportObject: thread,
85418548
parentReportActionID: createIOUAction?.reportActionID,
@@ -8841,6 +8848,7 @@ describe('actions/IOU', () => {
88418848
openReport({
88428849
reportID: thread.reportID,
88438850
introSelected: TEST_INTRO_SELECTED,
8851+
betas: undefined,
88448852
participantLoginList: userLogins,
88458853
newReportObject: thread,
88468854
parentReportActionID: createIOUAction?.reportActionID,
@@ -9012,6 +9020,7 @@ describe('actions/IOU', () => {
90129020
openReport({
90139021
reportID: thread.reportID,
90149022
introSelected: TEST_INTRO_SELECTED,
9023+
betas: undefined,
90159024
participantLoginList: userLogins,
90169025
newReportObject: thread,
90179026
parentReportActionID: createIOUAction?.reportActionID,
@@ -9281,6 +9290,7 @@ describe('actions/IOU', () => {
92819290
openReport({
92829291
reportID: thread.reportID,
92839292
introSelected: TEST_INTRO_SELECTED,
9293+
betas: undefined,
92849294
participantLoginList: userLogins,
92859295
newReportObject: thread,
92869296
parentReportActionID: createIOUAction?.reportActionID,
@@ -9380,6 +9390,7 @@ describe('actions/IOU', () => {
93809390
openReport({
93819391
reportID: thread.reportID,
93829392
introSelected: TEST_INTRO_SELECTED,
9393+
betas: undefined,
93839394
participantLoginList: userLogins,
93849395
newReportObject: thread,
93859396
parentReportActionID: createIOUAction?.reportActionID,
@@ -9679,6 +9690,7 @@ describe('actions/IOU', () => {
96799690
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
96809691
currentUserEmailParam: CARLOS_EMAIL,
96819692
isSelfTourViewed: false,
9693+
betas: undefined,
96829694
hasActiveAdminPolicies: false,
96839695
});
96849696

@@ -9826,6 +9838,7 @@ describe('actions/IOU', () => {
98269838
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
98279839
currentUserEmailParam: CARLOS_EMAIL,
98289840
isSelfTourViewed: false,
9841+
betas: undefined,
98299842
hasActiveAdminPolicies: false,
98309843
});
98319844

@@ -9907,6 +9920,7 @@ describe('actions/IOU', () => {
99079920
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
99089921
currentUserEmailParam: CARLOS_EMAIL,
99099922
isSelfTourViewed: false,
9923+
betas: undefined,
99109924
hasActiveAdminPolicies: false,
99119925
});
99129926
return waitForBatchedUpdates();
@@ -10176,6 +10190,7 @@ describe('actions/IOU', () => {
1017610190
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1017710191
currentUserEmailParam: CARLOS_EMAIL,
1017810192
isSelfTourViewed: false,
10193+
betas: undefined,
1017910194
hasActiveAdminPolicies: false,
1018010195
});
1018110196
return waitForBatchedUpdates();
@@ -10395,6 +10410,7 @@ describe('actions/IOU', () => {
1039510410
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1039610411
currentUserEmailParam: CARLOS_EMAIL,
1039710412
isSelfTourViewed: false,
10413+
betas: undefined,
1039810414
hasActiveAdminPolicies: false,
1039910415
});
1040010416
return waitForBatchedUpdates()
@@ -10623,6 +10639,7 @@ describe('actions/IOU', () => {
1062310639
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1062410640
currentUserEmailParam: CARLOS_EMAIL,
1062510641
isSelfTourViewed: false,
10642+
betas: undefined,
1062610643
hasActiveAdminPolicies: false,
1062710644
});
1062810645

@@ -13586,6 +13603,7 @@ describe('actions/IOU', () => {
1358613603
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1358713604
currentUserEmailParam: CARLOS_EMAIL,
1358813605
isSelfTourViewed: false,
13606+
betas: undefined,
1358913607
hasActiveAdminPolicies: false,
1359013608
});
1359113609
await waitForBatchedUpdates();
@@ -13688,6 +13706,7 @@ describe('actions/IOU', () => {
1368813706
currentUserEmailParam: CARLOS_EMAIL,
1368913707
activePolicyID: '123',
1369013708
isSelfTourViewed: false,
13709+
betas: undefined,
1369113710
hasActiveAdminPolicies: false,
1369213711
});
1369313712
await waitForBatchedUpdates();
@@ -14133,6 +14152,7 @@ describe('actions/IOU', () => {
1413314152
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1413414153
currentUserEmailParam: CARLOS_EMAIL,
1413514154
isSelfTourViewed: false,
14155+
betas: undefined,
1413614156
hasActiveAdminPolicies: false,
1413714157
});
1413814158

@@ -14308,6 +14328,7 @@ describe('actions/IOU', () => {
1430814328
currentUserAccountIDParam: RORY_ACCOUNT_ID,
1430914329
currentUserEmailParam: RORY_EMAIL,
1431014330
isSelfTourViewed: false,
14331+
betas: undefined,
1431114332
hasActiveAdminPolicies: false,
1431214333
});
1431314334

@@ -14487,6 +14508,7 @@ describe('actions/IOU', () => {
1448714508
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1448814509
currentUserEmailParam: CARLOS_EMAIL,
1448914510
isSelfTourViewed: false,
14511+
betas: undefined,
1449014512
hasActiveAdminPolicies: false,
1449114513
});
1449214514

@@ -14675,6 +14697,7 @@ describe('actions/IOU', () => {
1467514697
currentUserAccountIDParam: CARLOS_ACCOUNT_ID,
1467614698
currentUserEmailParam: CARLOS_EMAIL,
1467714699
isSelfTourViewed: false,
14700+
betas: undefined,
1467814701
hasActiveAdminPolicies: false,
1467914702
});
1468014703

tests/actions/IOUTest/DuplicateTest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,15 @@ describe('actions/Duplicate', () => {
427427
openReport({
428428
reportID: transactionThreadReport1.reportID,
429429
introSelected: undefined,
430+
betas: undefined,
430431
participantLoginList: userLogins,
431432
newReportObject: transactionThreadReport1,
432433
parentReportActionID: iouAction1?.reportActionID,
433434
});
434435
openReport({
435436
reportID: transactionThreadReport2.reportID,
436437
introSelected: undefined,
438+
betas: undefined,
437439
participantLoginList: userLogins,
438440
newReportObject: transactionThreadReport1,
439441
parentReportActionID: iouAction2?.reportActionID,

0 commit comments

Comments
 (0)