Skip to content

Commit

Permalink
Merge pull request Expensify#50066 from Expensify/georgia-ab-testing
Browse files Browse the repository at this point in the history
Allow all even accountIDs to use "Create Expense"
  • Loading branch information
techievivek authored Nov 11, 2024
2 parents d688a59 + d87db5f commit 3994e63
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
5 changes: 1 addition & 4 deletions src/libs/AccountUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import type {Account} from '@src/types/onyx';
const isValidateCodeFormSubmitting = (account: OnyxEntry<Account>) =>
!!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<Account>): boolean {
const delegateEmail = account?.delegatedAccess?.delegate;
const delegateRole = account?.delegatedAccess?.delegates?.find((delegate) => delegate.email === delegateEmail)?.role;

return delegateRole === CONST.DELEGATE_ROLE.SUBMITTER;
}

export default {isValidateCodeFormSubmitting, isAccountIDOddNumber, isDelegateOnlySubmitter};
export default {isValidateCodeFormSubmitting, isDelegateOnlySubmitter};
8 changes: 6 additions & 2 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import type Beta from '@src/types/onyx/Beta';
import * as SessionUtils from './SessionUtils';

const isAccountIDEven = (accountID: number) => accountID % 2 === 0;

function canUseAllBetas(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.ALL);
Expand All @@ -26,9 +29,10 @@ function canUseCategoryAndTagApprovers(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.CATEGORY_AND_TAG_APPROVERS) || canUseAllBetas(betas);
}

function canUseCombinedTrackSubmit(betas: OnyxEntry<Beta[]>): 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);
}

function canUsePerDiem(betas: OnyxEntry<Beta[]>): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7321,7 +7321,7 @@ function canCreateRequest(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>,
}

const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs);
if (Permissions.canUseCombinedTrackSubmit(allBetas ?? [])) {
if (Permissions.canUseCombinedTrackSubmit()) {
requestOptions.push(CONST.IOU.TYPE.CREATE);
}

Expand Down
9 changes: 1 addition & 8 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -280,12 +279,6 @@ Onyx.connect({
callback: (value) => (allReportDraftComments = value),
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let environmentURL: string;
Environment.getEnvironmentURL().then((url: string) => (environmentURL = url));

Expand Down Expand Up @@ -3431,7 +3424,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];
Expand Down

0 comments on commit 3994e63

Please sign in to comment.