From 643c5c47ab2d21208af360d62d1691c7a1f29e0e Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 2 Oct 2024 15:17:04 +0100 Subject: [PATCH 1/6] Allow all even accountIDs to use "Create Expense" --- src/libs/AccountUtils.ts | 5 +---- src/libs/Permissions.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/AccountUtils.ts b/src/libs/AccountUtils.ts index b5b58bfbf70c..2d44e4d5ec8f 100644 --- a/src/libs/AccountUtils.ts +++ b/src/libs/AccountUtils.ts @@ -5,9 +5,6 @@ import type {Account} from '@src/types/onyx'; const isValidateCodeFormSubmitting = (account: OnyxEntry) => !!account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); -/** Whether the accound ID is an odd number, useful for A/B testing. */ -const isAccountIDOddNumber = (accountID: number) => accountID % 2 === 1; - function isDelegateOnlySubmitter(account: OnyxEntry): boolean { const delegateEmail = account?.delegatedAccess?.delegate; const delegateRole = account?.delegatedAccess?.delegates?.find((delegate) => delegate.email === delegateEmail)?.role; @@ -15,4 +12,4 @@ function isDelegateOnlySubmitter(account: OnyxEntry): boolean { return delegateRole === CONST.DELEGATE_ROLE.SUBMITTER; } -export default {isValidateCodeFormSubmitting, isAccountIDOddNumber, isDelegateOnlySubmitter}; +export default {isValidateCodeFormSubmitting, isDelegateOnlySubmitter}; diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 7f7e89ad3585..e64d1f8b8a80 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -3,6 +3,9 @@ import CONST from '@src/CONST'; import type {IOUType} from '@src/CONST'; import type Beta from '@src/types/onyx/Beta'; import * as Environment from './Environment/Environment'; +import * as SessionUtils from './SessionUtils'; + +const isAccountIDEven = (accountID: number) => accountID % 2 === 0; function canUseAllBetas(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.ALL); @@ -45,9 +48,10 @@ function canUseWorkspaceRules(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.WORKSPACE_RULES) || canUseAllBetas(betas); } -function canUseCombinedTrackSubmit(betas: OnyxEntry): boolean { +function canUseCombinedTrackSubmit(): boolean { // We don't need to show this to all betas since this will be used for developing a feature for A/B testing. - return !!betas?.includes(CONST.BETAS.COMBINED_TRACK_SUBMIT); + const session = SessionUtils.getSession(); + return isAccountIDEven(session?.accountID ?? -1); } /** From 3791a3238c128e1dfa1605a810a573bb510646ae Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 2 Oct 2024 15:26:47 +0100 Subject: [PATCH 2/6] fix function call --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 687ef177609e..e5b749750520 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6961,7 +6961,7 @@ function canCreateRequest(report: OnyxEntry, policy: OnyxEntry, } const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs); - if (Permissions.canUseCombinedTrackSubmit(allBetas ?? [])) { + if (Permissions.canUseCombinedTrackSubmit()) { requestOptions.push(CONST.IOU.TYPE.CREATE); } From ce1afd9f753bbda3f7fa4fe2c880063d3cfd1272 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 7 Nov 2024 14:16:41 +0000 Subject: [PATCH 3/6] Remove unused import --- src/libs/Permissions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 3c18825a0231..1d3428dfcfce 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -1,7 +1,6 @@ import type {OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import type Beta from '@src/types/onyx/Beta'; -import * as Environment from './Environment/Environment'; import * as SessionUtils from './SessionUtils'; const isAccountIDEven = (accountID: number) => accountID % 2 === 0; From d7cacbb9add1d89a689983cd411224fa37371bdc Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Thu, 7 Nov 2024 17:01:23 +0000 Subject: [PATCH 4/6] fix last TS error --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 9ea499283d70..649e494177be 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3426,7 +3426,7 @@ function completeOnboarding( userReportedIntegration?: OnboardingAccountingType, ) { // If the user has the "combinedTrackSubmit" beta enabled we'll show different tasks for track and submit expense. - if (Permissions.canUseCombinedTrackSubmit(allBetas)) { + if (Permissions.canUseCombinedTrackSubmit()) { if (engagementChoice === CONST.ONBOARDING_CHOICES.PERSONAL_SPEND) { // eslint-disable-next-line no-param-reassign data = CONST.COMBINED_TRACK_SUBMIT_ONBOARDING_MESSAGES[CONST.ONBOARDING_CHOICES.PERSONAL_SPEND]; From 6dc5f37fb28872a5d020a3ceebdf5a3b78d6ab06 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Fri, 8 Nov 2024 17:13:54 +0000 Subject: [PATCH 5/6] eslint --- src/libs/actions/Report.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 98ff380bb870..0d8b3f6cb2b6 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -280,12 +280,6 @@ Onyx.connect({ callback: (value) => (allReportDraftComments = value), }); -let allBetas: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.BETAS, - callback: (value) => (allBetas = value), -}); - let environmentURL: string; Environment.getEnvironmentURL().then((url: string) => (environmentURL = url)); From d87db5f598dae2b39e6fca56d9e9ad94ab528c40 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Fri, 8 Nov 2024 17:21:26 +0000 Subject: [PATCH 6/6] eslint --- src/libs/actions/Report.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0d8b3f6cb2b6..e3eb839fe1d8 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -96,7 +96,6 @@ import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/NewRoomForm'; import type { - Beta, InvitedEmailsToAccountIDs, NewGroupChatDraft, PersonalDetailsList,