diff --git a/src/components/AddUnreportedExpenseFooter.tsx b/src/components/AddUnreportedExpenseFooter.tsx index 51249d046743a..53c506524f96a 100644 --- a/src/components/AddUnreportedExpenseFooter.tsx +++ b/src/components/AddUnreportedExpenseFooter.tsx @@ -45,7 +45,6 @@ function AddUnreportedExpenseFooter({selectedIds, report, reportToConfirm, repor const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const handleConfirm = () => { if (selectedIds.size === 0) { @@ -64,7 +63,6 @@ function AddUnreportedExpenseFooter({selectedIds, report, reportToConfirm, repor session?.email ?? '', transactionViolations, policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, ); } else { diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index a62c8c5501f66..5ecd5a62ce269 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -204,7 +204,6 @@ function MoneyReportHeader({ const {login: currentUserLogin, accountID, email} = useCurrentUserPersonalDetails(); const defaultExpensePolicy = useDefaultExpensePolicy(); const activePolicyExpenseChat = getPolicyExpenseChat(accountID, defaultExpensePolicy?.id); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`, {canBeMissing: true}); const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID}`, {canBeMissing: true}); const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isUserValidatedSelector, canBeMissing: true}); @@ -550,11 +549,10 @@ function MoneyReportHeader({ methodID, paymentMethod, activePolicy, - allBetas, }); } else { startAnimation(); - payMoneyRequest(type, chatReport, moneyRequestReport, introSelected, nextStep, allBetas, undefined, true, activePolicy, policy); + payMoneyRequest(type, chatReport, moneyRequestReport, introSelected, nextStep, undefined, true, activePolicy, policy); if (currentSearchQueryJSON && !isOffline) { search({ searchKey: currentSearchKey, @@ -587,7 +585,6 @@ function MoneyReportHeader({ currentSearchKey, shouldCalculateTotals, currentSearchResults?.search?.isLoading, - allBetas, ], ); @@ -616,7 +613,7 @@ function MoneyReportHeader({ setIsHoldMenuVisible(true); } else { startApprovedAnimation(); - approveMoneyRequest(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, allBetas, true); + approveMoneyRequest(moneyRequestReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, nextStep, true); } }; @@ -655,11 +652,10 @@ function MoneyReportHeader({ targetPolicy: defaultExpensePolicy ?? undefined, targetPolicyCategories: activePolicyCategories, targetReport: activePolicyExpenseChat, - allBetas, }); } }, - [activePolicyExpenseChat, activePolicyID, allPolicyCategories, defaultExpensePolicy, introSelected, isASAPSubmitBetaEnabled, quickAction, policyRecentlyUsedCurrencies, allBetas], + [activePolicyExpenseChat, activePolicyID, allPolicyCategories, defaultExpensePolicy, introSelected, isASAPSubmitBetaEnabled, quickAction, policyRecentlyUsedCurrencies], ); const getStatusIcon: (src: IconAsset) => React.ReactNode = (src) => ( @@ -1098,7 +1094,6 @@ function MoneyReportHeader({ reportMetadata, policies, isChatReportArchived, - allBetas, }); }, [ moneyRequestReport, @@ -1115,7 +1110,6 @@ function MoneyReportHeader({ policies, isChatReportArchived, bankAccountList, - allBetas, ]); const secondaryExportActions = useMemo(() => { @@ -1659,7 +1653,6 @@ function MoneyReportHeader({ confirmApproval, iouReport: moneyRequestReport, iouReportNextStep: nextStep, - allBetas, }); const showNextStepBar = shouldShowNextStep && !!optimisticNextStep?.message?.length; diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 4c8f9133e73fa..4d76735f1acbf 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -113,7 +113,6 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre }`, {canBeMissing: true}, ); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [originalTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transaction?.comment?.originalTransactionID)}`, {canBeMissing: true}); const [transactionReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(transaction?.reportID)}`, {canBeMissing: true}); const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getNonEmptyStringOnyxID(transactionReport?.policyID)}`, {canBeMissing: true}); @@ -200,11 +199,10 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre targetPolicy: defaultExpensePolicy ?? undefined, targetPolicyCategories: activePolicyCategories, targetReport: activePolicyExpenseChat, - allBetas, }); } }, - [activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled, introSelected, activePolicyID, quickAction, policyRecentlyUsedCurrencies, allBetas], + [activePolicyExpenseChat, allPolicyCategories, defaultExpensePolicy, isASAPSubmitBetaEnabled, introSelected, activePolicyID, quickAction, policyRecentlyUsedCurrencies], ); const getStatusIcon: (src: IconAsset) => ReactNode = (src) => ( diff --git a/src/components/ProcessMoneyReportHoldMenu.tsx b/src/components/ProcessMoneyReportHoldMenu.tsx index 2eae75fbf9fc7..f90caa0849161 100644 --- a/src/components/ProcessMoneyReportHoldMenu.tsx +++ b/src/components/ProcessMoneyReportHoldMenu.tsx @@ -81,7 +81,6 @@ function ProcessMoneyReportHoldMenu({ const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const currentUserDetails = useCurrentUserPersonalDetails(); const hasViolations = hasViolationsReportUtils(moneyRequestReport?.reportID, transactionViolations, currentUserDetails.accountID, currentUserDetails.email ?? ''); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const onSubmit = (full: boolean) => { @@ -102,14 +101,13 @@ function ProcessMoneyReportHoldMenu({ hasViolations, isASAPSubmitBetaEnabled, moneyRequestReportNextStep, - allBetas, full, ); } else if (chatReport && paymentType) { if (startAnimation) { startAnimation(); } - payMoneyRequest(paymentType, chatReport, moneyRequestReport, introSelected, moneyRequestReportNextStep, allBetas, undefined, full, activePolicy, policy); + payMoneyRequest(paymentType, chatReport, moneyRequestReport, introSelected, moneyRequestReportNextStep, undefined, full, activePolicy, policy); } onClose(); }; diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index bf8162b7a3e3f..d36c1dad5985c 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -176,7 +176,7 @@ function MoneyRequestReportPreviewContent({ const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW); const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, currentUserAccountID, currentUserEmail); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const getCanIOUBePaid = useCallback( (shouldShowOnlyPayElsewhere = false) => canIOUBePaidIOUActions(iouReport, chatReport, policy, bankAccountList, transactions, shouldShowOnlyPayElsewhere), [iouReport, chatReport, policy, bankAccountList, transactions], @@ -267,10 +267,9 @@ function MoneyRequestReportPreviewContent({ methodID, paymentMethod, activePolicy, - allBetas, }); } else { - payMoneyRequest(type, chatReport, iouReport, introSelected, iouReportNextStep, allBetas, undefined, true, activePolicy, policy); + payMoneyRequest(type, chatReport, iouReport, introSelected, iouReportNextStep, undefined, true, activePolicy, policy); } } }, @@ -287,7 +286,6 @@ function MoneyRequestReportPreviewContent({ existingB2BInvoiceReport, activePolicy, policy, - allBetas, ], ); @@ -303,7 +301,7 @@ function MoneyRequestReportPreviewContent({ setIsHoldMenuVisible(true); } else { startApprovedAnimation(); - approveMoneyRequest(iouReport, activePolicy, currentUserAccountID, currentUserEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, allBetas, true); + approveMoneyRequest(iouReport, activePolicy, currentUserAccountID, currentUserEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, true); } }; diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 39ffea4296402..332d6cf56b6a3 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -54,7 +54,6 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const {environmentURL} = useEnvironment(); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsSelector, canBeMissing: false}); const {isRestrictedToPreferredPolicy} = usePreferredPolicy(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID || undefined}`, {canBeMissing: true}); @@ -65,7 +64,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const isSystemChat = isSystemChatReportUtils(report); const isDefault = !(isChatRoom || isPolicyExpenseChat || isSelfDM || isSystemChat); const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, true, true, reportMetadata); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, allBetas, isReportArchived, isRestrictedToPreferredPolicy); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, policy, participantAccountIDs, isReportArchived, isRestrictedToPreferredPolicy); const policyName = getPolicyName({report}); const filteredOptions = moneyRequestOptions.filter( diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index f31712cda9fbe..2d7071ba7b899 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -124,7 +124,6 @@ function SettlementButton({ const activeAdminPolicies = getActiveAdminWorkspaces(policies, accountID.toString()).sort((a, b) => localeCompare(a.name || '', b.name || '')); const reportID = iouReport?.reportID; const personalPolicy = usePolicy(personalPolicyID); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const hasPreferredPaymentMethod = !!lastPaymentMethod; const lastPaymentPolicy = usePolicy(lastPaymentMethod); @@ -425,7 +424,7 @@ function SettlementButton({ if (confirmApproval) { confirmApproval(); } else { - approveMoneyRequest(iouReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, allBetas, false); + approveMoneyRequest(iouReport, policy, accountID, email ?? '', hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, false); } return; } diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index c1e0395b980f3..68e5e38fc6bee 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -35,7 +35,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true}); const [iouReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${getNonEmptyStringOnyxID(report?.reportID)}`, {canBeMissing: true}); @@ -150,7 +149,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac currentUserPersonalDetails, transactionViolations, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, iouReportNextStep, }); @@ -199,7 +197,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac policy, policyCategories, policyRecentlyUsedCurrencies, - allBetas, quickAction, report, reportActions, diff --git a/src/libs/PaymentUtils.ts b/src/libs/PaymentUtils.ts index 032a782cbdd42..3c522efa96863 100644 --- a/src/libs/PaymentUtils.ts +++ b/src/libs/PaymentUtils.ts @@ -11,7 +11,7 @@ import type {BankAccountMenuItem} from '@components/Search/types'; import type {ThemeStyles} from '@styles/index'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type {Beta, Policy, Report, ReportNextStepDeprecated} from '@src/types/onyx'; +import type {Policy, Report, ReportNextStepDeprecated} from '@src/types/onyx'; import type BankAccount from '@src/types/onyx/BankAccount'; import type Fund from '@src/types/onyx/Fund'; import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage'; @@ -41,7 +41,6 @@ type SelectPaymentTypeParams = { confirmApproval?: () => void; iouReport?: OnyxEntry; iouReportNextStep: OnyxEntry; - allBetas: OnyxEntry; }; /** @@ -177,7 +176,6 @@ const selectPaymentType = (params: SelectPaymentTypeParams) => { confirmApproval, iouReport, iouReportNextStep, - allBetas, } = params; if (policy && shouldRestrictUserBillableActions(policy.id)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); @@ -197,7 +195,7 @@ const selectPaymentType = (params: SelectPaymentTypeParams) => { if (confirmApproval) { confirmApproval(); } else { - approveMoneyRequest(iouReport, policy, currentAccountID, currentEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, allBetas, true); + approveMoneyRequest(iouReport, policy, currentAccountID, currentEmail, hasViolations, isASAPSubmitBetaEnabled, iouReportNextStep, true); } return; } diff --git a/src/libs/QuickActionUtils.ts b/src/libs/QuickActionUtils.ts index 5ea0cc98e16dd..f26ef936b1ffa 100644 --- a/src/libs/QuickActionUtils.ts +++ b/src/libs/QuickActionUtils.ts @@ -1,7 +1,6 @@ -import type {OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; -import type {Beta, Policy, Report} from '@src/types/onyx'; +import type {Policy, Report} from '@src/types/onyx'; import type {QuickActionName} from '@src/types/onyx/QuickAction'; import type QuickAction from '@src/types/onyx/QuickAction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -100,7 +99,6 @@ const isQuickActionAllowed = ( quickActionReport: Report | undefined, quickActionPolicy: Policy | undefined, isReportArchived: boolean | undefined, - allBetas: OnyxEntry, isRestrictedToPreferredPolicy = false, ) => { if (quickAction?.action === CONST.QUICK_ACTIONS.PER_DIEM) { @@ -119,7 +117,7 @@ const isQuickActionAllowed = ( if (isReportHasManagerMCTest) { return false; } - return canCreateRequest(quickActionReport, quickActionPolicy, iouType, isReportArchived, allBetas, isRestrictedToPreferredPolicy); + return canCreateRequest(quickActionReport, quickActionPolicy, iouType, isReportArchived, isRestrictedToPreferredPolicy); } return true; }; diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index 48637de9f75f2..ff7ef7ca94aad 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -2,7 +2,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {BankAccountList, Beta, ExportTemplate, Policy, Report, ReportAction, ReportMetadata, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx'; +import type {BankAccountList, ExportTemplate, Policy, Report, ReportAction, ReportMetadata, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx'; import {isApprover as isApproverUtils} from './actions/Policy/Member'; import {areTransactionsEligibleForMerge} from './MergeTransactionUtils'; import {getLoginByAccountID} from './PersonalDetailsUtils'; @@ -538,9 +538,9 @@ function isHoldActionForTransaction(report: Report, reportTransaction: Transacti return isProcessingReport; } -function isChangeWorkspaceAction(report: Report, policies: OnyxCollection, allBetas: OnyxEntry, reportActions?: ReportAction[]): boolean { +function isChangeWorkspaceAction(report: Report, policies: OnyxCollection, reportActions?: ReportAction[]): boolean { // We can't move the iou report to the workspace if both users from the iou report create the expense - if (isIOUReportUtils(report) && doesReportContainRequestsFromMultipleUsers(report, allBetas)) { + if (isIOUReportUtils(report) && doesReportContainRequestsFromMultipleUsers(report)) { return false; } @@ -792,7 +792,6 @@ function getSecondaryReportActions({ reportMetadata, policies, isChatReportArchived = false, - allBetas, }: { currentUserLogin: string; currentUserAccountID: number; @@ -802,7 +801,6 @@ function getSecondaryReportActions({ originalTransaction: OnyxEntry; violations: OnyxCollection; bankAccountList: OnyxEntry; - allBetas: OnyxEntry; policy?: Policy; reportNameValuePairs?: ReportNameValuePairs; reportActions?: ReportAction[]; @@ -909,7 +907,7 @@ function getSecondaryReportActions({ options.push(CONST.REPORT.SECONDARY_ACTIONS.DOWNLOAD_PDF); - if (isChangeWorkspaceAction(report, policies, allBetas, reportActions)) { + if (isChangeWorkspaceAction(report, policies, reportActions)) { options.push(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3eb07cbd3a590..05d490dfee854 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -464,20 +464,6 @@ type BuildOptimisticIOUReportActionParams = { reportActionID?: string; }; -type BuildOptimisticExpenseReportParams = { - chatReportID: string | undefined; - policyID: string | undefined; - payeeAccountID: number; - total: number; - currency: string; - allBetas: OnyxEntry; - nonReimbursableTotal?: number; - parentReportActionID?: string; - optimisticIOUReportID?: string; - reportTransactions?: Record; - createdTimestamp?: string; -}; - type OptimisticIOUReportAction = Pick< ReportAction, | 'actionName' @@ -1116,6 +1102,12 @@ Onyx.connectWithoutView({ }, }); +let allBetas: OnyxEntry; +Onyx.connectWithoutView({ + key: ONYXKEYS.BETAS, + callback: (value) => (allBetas = value), +}); + let allTransactions: OnyxCollection = {}; let reportsTransactions: Record = {}; Onyx.connectWithoutView({ @@ -6772,7 +6764,7 @@ function buildOptimisticInvoiceReport( * Returns the stateNum and statusNum for an expense report based on the policy settings * @param policy */ -function getExpenseReportStateAndStatus(policy: OnyxEntry, allBetas: OnyxEntry, isEmptyOptimisticReport = false) { +function getExpenseReportStateAndStatus(policy: OnyxEntry, isEmptyOptimisticReport = false) { const isASAPSubmitBetaEnabled = Permissions.isBetaEnabled(CONST.BETAS.ASAP_SUBMIT, allBetas); if (isASAPSubmitBetaEnabled) { return { @@ -6816,19 +6808,18 @@ function getExpenseReportStateAndStatus(policy: OnyxEntry, allBetas: Ony * @param parentReportActionID – The parent ReportActionID of the PolicyExpenseChat * @param optimisticIOUReportID – Optimistic IOU report id */ -function buildOptimisticExpenseReport({ - chatReportID, - policyID, - payeeAccountID, - total, - currency, - allBetas, +function buildOptimisticExpenseReport( + chatReportID: string | undefined, + policyID: string | undefined, + payeeAccountID: number, + total: number, + currency: string, nonReimbursableTotal = 0, - parentReportActionID, - optimisticIOUReportID, - reportTransactions, - createdTimestamp, -}: BuildOptimisticExpenseReportParams): OptimisticExpenseReport { + parentReportActionID?: string, + optimisticIOUReportID?: string, + reportTransactions?: Record, + createdTimestamp?: string, +): OptimisticExpenseReport { // The amount for Expense reports are stored as negative value in the database const storedTotal = total * -1; const storedNonReimbursableTotal = nonReimbursableTotal * -1; @@ -6841,7 +6832,7 @@ function buildOptimisticExpenseReport({ const policyDraft = allPolicyDrafts?.[`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`]; const policy = policyReal ?? policyDraft; - const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy, allBetas); + const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy); const created = createdTimestamp ?? DateUtils.getDBTime(); @@ -6900,16 +6891,8 @@ function buildOptimisticExpenseReport({ return expenseReport; } -function buildOptimisticEmptyReport( - reportID: string, - accountID: number, - parentReport: OnyxEntry, - parentReportActionID: string, - policy: OnyxEntry, - timeOfCreation: string, - allBetas: OnyxEntry, -) { - const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy, allBetas, true); +function buildOptimisticEmptyReport(reportID: string, accountID: number, parentReport: OnyxEntry, parentReportActionID: string, policy: OnyxEntry, timeOfCreation: string) { + const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy, true); const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policy?.id) ?? {}); const optimisticEmptyReport: OptimisticNewReport = { reportName: '', @@ -9917,7 +9900,6 @@ function getMoneyRequestOptions( report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], - allBetas: OnyxEntry, filterDeprecatedTypes = false, isReportArchived = false, isRestrictedToPreferredPolicy = false, @@ -10035,11 +10017,10 @@ function temporary_getMoneyRequestOptions( report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], - allBetas: OnyxEntry, isReportArchived = false, isRestrictedToPreferredPolicy = false, ): Array> { - return getMoneyRequestOptions(report, policy, reportParticipants, allBetas, true, isReportArchived, isRestrictedToPreferredPolicy) as Array< + return getMoneyRequestOptions(report, policy, reportParticipants, true, isReportArchived, isRestrictedToPreferredPolicy) as Array< Exclude >; } @@ -10250,7 +10231,6 @@ function canCreateRequest( policy: OnyxEntry, iouType: ValueOf, isReportArchived: boolean | undefined, - allBetas: OnyxEntry, isRestrictedToPreferredPolicy = false, ): boolean { const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); @@ -10259,7 +10239,7 @@ function canCreateRequest( return false; } - const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs, allBetas, false, isReportArchived, isRestrictedToPreferredPolicy); + const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs, false, isReportArchived, isRestrictedToPreferredPolicy); requestOptions.push(CONST.IOU.TYPE.CREATE); return requestOptions.includes(iouType); @@ -10627,7 +10607,7 @@ function isReportParticipant(accountID: number | undefined, report: OnyxEntry, allBetas: OnyxEntry, isReportArchived = false): boolean { +function canCurrentUserOpenReport(report: OnyxEntry, isReportArchived = false): boolean { return (isReportParticipant(currentUserAccountID, report) || isPublicRoom(report)) && canAccessReport(report, allBetas, isReportArchived); } @@ -11090,7 +11070,6 @@ function shouldCreateNewMoneyRequestReport( existingIOUReport: OnyxInputOrEntry | undefined, chatReport: OnyxInputOrEntry, isScanRequest: boolean, - allBetas: OnyxEntry, action?: IOUAction, ): boolean { if (existingIOUReport && !!existingIOUReport.errorFields?.createChat) { @@ -12427,7 +12406,7 @@ function hasExportError(reportActions: OnyxEntry | ReportAction[] return Object.values(reportActions).some((action) => isIntegrationMessageAction(action)); } -function doesReportContainRequestsFromMultipleUsers(iouReport: OnyxEntry, allBetas: OnyxEntry): boolean { +function doesReportContainRequestsFromMultipleUsers(iouReport: OnyxEntry): boolean { const transactions = getReportTransactions(iouReport?.reportID); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing if (Permissions.isBetaEnabled(CONST.BETAS.ZERO_EXPENSES, allBetas)) { diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index d7e0205efbe4a..da8822844c319 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -462,7 +462,6 @@ type DuplicateExpenseTransactionParams = { targetPolicy?: OnyxEntry; targetPolicyCategories?: OnyxEntry; targetReport?: OnyxTypes.Report; - allBetas: OnyxEntry; }; function duplicateExpenseTransaction({ @@ -477,7 +476,6 @@ function duplicateExpenseTransaction({ targetPolicy, targetPolicyCategories, targetReport, - allBetas, }: DuplicateExpenseTransactionParams) { if (!transaction) { return; @@ -529,7 +527,6 @@ function duplicateExpenseTransaction({ transactionViolations: {}, policyRecentlyUsedCurrencies, quickAction, - allBetas, }; // If no workspace is provided the expense should be unreported diff --git a/src/libs/actions/IOU/MoneyRequest.ts b/src/libs/actions/IOU/MoneyRequest.ts index 67977cc7cb5a3..12249e8a3ef85 100644 --- a/src/libs/actions/IOU/MoneyRequest.ts +++ b/src/libs/actions/IOU/MoneyRequest.ts @@ -17,7 +17,7 @@ import CONST from '@src/CONST'; import type {TranslationParameters, TranslationPaths} from '@src/languages/types'; import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; -import type {Beta, IntroSelected, LastSelectedDistanceRates, PersonalDetailsList, Policy, QuickAction, Report, Transaction, TransactionViolation} from '@src/types/onyx'; +import type {IntroSelected, LastSelectedDistanceRates, PersonalDetailsList, Policy, QuickAction, Report, Transaction, TransactionViolation} from '@src/types/onyx'; import type {ReportAttributes, ReportAttributesDerivedValue} from '@src/types/onyx/DerivedValues'; import type {Participant} from '@src/types/onyx/IOU'; import type {Receipt, WaypointCollection} from '@src/types/onyx/Transaction'; @@ -57,7 +57,6 @@ type CreateTransactionParams = { policyParams?: {policy: OnyxEntry}; billable?: boolean; reimbursable?: boolean; - allBetas: OnyxEntry; }; type InitialTransactionParams = { @@ -98,7 +97,6 @@ type MoneyRequestStepScanParticipantsFlowParams = { isTestTransaction?: boolean; locationPermissionGranted?: boolean; shouldGenerateTransactionThreadReport: boolean; - allBetas: OnyxEntry; }; type MoneyRequestStepDistanceNavigationParams = { @@ -131,7 +129,6 @@ type MoneyRequestStepDistanceNavigationParams = { introSelected?: IntroSelected; activePolicyID?: string; privateIsArchived?: string; - allBetas: OnyxEntry; }; function createTransaction({ @@ -154,7 +151,6 @@ function createTransaction({ policyParams, billable, reimbursable = true, - allBetas, }: CreateTransactionParams) { for (const [index, receiptFile] of files.entries()) { const transaction = transactions.find((item) => item.transactionID === receiptFile.transactionID); @@ -187,7 +183,6 @@ function createTransaction({ introSelected, activePolicyID, quickAction, - allBetas, }); } else { requestMoney({ @@ -218,7 +213,6 @@ function createTransaction({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); } } @@ -267,7 +261,6 @@ function handleMoneyRequestStepScanParticipants({ files, isTestTransaction = false, locationPermissionGranted = false, - allBetas, }: MoneyRequestStepScanParticipantsFlowParams) { if (backTo) { Navigation.goBack(backTo); @@ -361,7 +354,6 @@ function handleMoneyRequestStepScanParticipants({ policyParams, billable: false, reimbursable: true, - allBetas, }); }, (errorData) => { @@ -383,7 +375,6 @@ function handleMoneyRequestStepScanParticipants({ activePolicyID, files, participant, - allBetas, }); }, ); @@ -405,7 +396,6 @@ function handleMoneyRequestStepScanParticipants({ activePolicyID, files, participant, - allBetas, }); return; } @@ -493,7 +483,6 @@ function handleMoneyRequestStepDistanceNavigation({ introSelected, activePolicyID, privateIsArchived, - allBetas, }: MoneyRequestStepDistanceNavigationParams) { const isManualDistance = manualDistance !== undefined; @@ -550,7 +539,6 @@ function handleMoneyRequestStepDistanceNavigation({ introSelected, activePolicyID, quickAction, - allBetas, }); return; } @@ -582,7 +570,6 @@ function handleMoneyRequestStepDistanceNavigation({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); return; } diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 14536bd488f86..45d4ef1e97f26 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -322,7 +322,6 @@ type PayInvoiceArgs = { methodID?: number; paymentMethod?: PaymentMethod; activePolicy?: OnyxTypes.Policy; - allBetas: OnyxEntry; }; type RejectMoneyRequestData = { @@ -503,7 +502,6 @@ type PerDiemExpenseInformation = { hasViolations: boolean; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type PerDiemExpenseInformationParams = { @@ -519,7 +517,6 @@ type PerDiemExpenseInformationParams = { hasViolations: boolean; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type RequestMoneyInformation = { @@ -545,7 +542,6 @@ type RequestMoneyInformation = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type MoneyRequestInformationParams = { @@ -575,7 +571,6 @@ type MoneyRequestInformationParams = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type MoneyRequestOptimisticParams = { @@ -647,7 +642,6 @@ type CreateDistanceRequestInformation = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type CreateSplitsTransactionParams = Omit & { @@ -668,7 +662,6 @@ type CreateSplitsAndOnyxDataParams = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; type TrackExpenseTransactionParams = { @@ -718,7 +711,6 @@ type CreateTrackExpenseParams = { introSelected: OnyxEntry; activePolicyID: string | undefined; quickAction: OnyxEntry; - allBetas: OnyxEntry; }; type GetTrackExpenseInformationTransactionParams = { @@ -761,7 +753,6 @@ type GetTrackExpenseInformationParams = { introSelected: OnyxEntry; activePolicyID: string | undefined; quickAction: OnyxEntry; - allBetas: OnyxEntry; }; let allPersonalDetails: OnyxTypes.PersonalDetailsList = {}; @@ -814,7 +805,6 @@ type UpdateSplitTransactionsParams = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; iouReportNextStep: OnyxEntry; }; @@ -3052,7 +3042,6 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } = moneyRequestInformation; const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -3121,7 +3110,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma } const isScanRequest = isScanRequestTransactionUtils({amount, receipt}); - const shouldCreateNewMoneyRequestReport = isSplitExpense ? false : shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest, allBetas, action); + const shouldCreateNewMoneyRequestReport = isSplitExpense ? false : shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest, action); // Generate IDs upfront so we can pass them to buildOptimisticExpenseReport for formula computation const optimisticTransactionID = existingTransactionID ?? NumberUtils.rand64(); @@ -3132,17 +3121,17 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma const reportTransactions = buildMinimalTransactionForFormula(optimisticTransactionID, optimisticReportID, created, amount, currency, merchant); iouReport = isPolicyExpenseChat - ? buildOptimisticExpenseReport({ - chatReportID: chatReport.reportID, - policyID: chatReport.policyID, + ? buildOptimisticExpenseReport( + chatReport.reportID, + chatReport.policyID, payeeAccountID, - total: amount, + amount, currency, - allBetas, nonReimbursableTotal, - optimisticIOUReportID: optimisticReportID, + undefined, + optimisticReportID, reportTransactions, - }) + ) : buildOptimisticIOUReport(payeeAccountID, payerAccountID, amount, chatReport.reportID, currency, undefined, undefined, optimisticReportID); } else if (isPolicyExpenseChat) { iouReport = {...iouReport}; @@ -3468,7 +3457,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI hasViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } = perDiemExpenseInformation; const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; @@ -3515,7 +3503,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null; } - const shouldCreateNewMoneyRequestReport = shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, false, allBetas); + const shouldCreateNewMoneyRequestReport = shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, false); // Generate IDs upfront so we can pass them to buildOptimisticExpenseReport for formula computation const optimisticTransactionID = NumberUtils.rand64(); @@ -3525,16 +3513,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI const reportTransactions = buildMinimalTransactionForFormula(optimisticTransactionID, optimisticReportID, created, amount, currency, merchant); iouReport = isPolicyExpenseChat - ? buildOptimisticExpenseReport({ - chatReportID: chatReport.reportID, - policyID: chatReport.policyID, - payeeAccountID, - total: amount, - currency, - allBetas, - optimisticIOUReportID: optimisticReportID, - reportTransactions, - }) + ? buildOptimisticExpenseReport(chatReport.reportID, chatReport.policyID, payeeAccountID, amount, currency, undefined, undefined, optimisticReportID, reportTransactions) : buildOptimisticIOUReport(payeeAccountID, payerAccountID, amount, chatReport.reportID, currency); } else if (isPolicyExpenseChat) { iouReport = {...iouReport}; @@ -3738,7 +3717,6 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T introSelected, activePolicyID, quickAction, - allBetas, } = params; const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; const {policy, policyCategories, policyTagList} = policyParams; @@ -3897,21 +3875,21 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null; } const isScanRequest = isScanRequestTransactionUtils({amount, receipt}); - shouldCreateNewMoneyRequestReport = shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest, allBetas); + shouldCreateNewMoneyRequestReport = shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, isScanRequest); if (!iouReport || shouldCreateNewMoneyRequestReport) { const reportTransactions = buildMinimalTransactionForFormula(optimisticTransactionID, optimisticExpenseReportID, created, amount, currency, merchant); - iouReport = buildOptimisticExpenseReport({ - chatReportID: chatReport.reportID, - policyID: chatReport.policyID, + iouReport = buildOptimisticExpenseReport( + chatReport.reportID, + chatReport.policyID, payeeAccountID, - total: amount, + amount, currency, - allBetas, - nonReimbursableTotal: amount, - optimisticIOUReportID: optimisticExpenseReportID, + amount, + undefined, + optimisticExpenseReportID, reportTransactions, - }); + ); } else { iouReport = {...iouReport}; // Because of the Expense reports are stored as negative values, we subtract the total from the amount @@ -5783,7 +5761,6 @@ function convertBulkTrackedExpensesToIOU( currentUserEmailParam: string, transactionViolations: OnyxCollection, policyRecentlyUsedCurrencies: string[], - allBetas: OnyxEntry, quickAction: OnyxEntry, ) { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${targetReportID}`]; @@ -5907,7 +5884,6 @@ function convertBulkTrackedExpensesToIOU( transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); const convertParams: ConvertTrackedExpenseToRequestParams = { @@ -6144,7 +6120,6 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } = requestMoneyInformation; const {payeeAccountID} = participantParams; const parsedComment = getParsedComment(transactionParams.comment ?? ''); @@ -6243,7 +6218,6 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation): {iouRep transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport.reportID; @@ -6409,7 +6383,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf hasViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } = submitPerDiemExpenseInformation; const {payeeAccountID} = participantParams; const {currency, comment = '', category, tag, created, customUnit, attendees} = transactionParams; @@ -6456,7 +6429,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf hasViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); const activeReportID = isMoneyRequestReport && Navigation.getTopmostReportId() === report?.reportID ? report?.reportID : chatReport.reportID; @@ -6526,7 +6498,6 @@ function trackExpense(params: CreateTrackExpenseParams) { introSelected, activePolicyID, quickAction, - allBetas, } = params; const {participant, payeeAccountID, payeeEmail} = participantParams; const {policy, policyCategories, policyTagList} = policyData; @@ -6658,7 +6629,6 @@ function trackExpense(params: CreateTrackExpenseParams) { introSelected, activePolicyID, quickAction, - allBetas, }) ?? {}; const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport?.reportID; @@ -6920,7 +6890,6 @@ function createSplitsAndOnyxData({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }: CreateSplitsAndOnyxDataParams): SplitsAndOnyxData { const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -7197,7 +7166,7 @@ function createSplitsAndOnyxData({ // STEP 2: Get existing IOU/Expense report and update its total OR build a new optimistic one let oneOnOneIOUReport: OneOnOneIOUReport = oneOnOneChatReport.iouReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneOnOneChatReport.iouReportID}`] : null; const isScanRequest = isScanRequestTransactionUtils(splitTransaction); - const shouldCreateNewOneOnOneIOUReport = shouldCreateNewMoneyRequestReportReportUtils(oneOnOneIOUReport, oneOnOneChatReport, isScanRequest, allBetas); + const shouldCreateNewOneOnOneIOUReport = shouldCreateNewMoneyRequestReportReportUtils(oneOnOneIOUReport, oneOnOneChatReport, isScanRequest); if (!oneOnOneIOUReport || shouldCreateNewOneOnOneIOUReport) { const optimisticExpenseReportID = generateReportID(); @@ -7211,16 +7180,17 @@ function createSplitsAndOnyxData({ ); oneOnOneIOUReport = isOwnPolicyExpenseChat - ? buildOptimisticExpenseReport({ - chatReportID: oneOnOneChatReport.reportID, - policyID: oneOnOneChatReport.policyID, - payeeAccountID: currentUserAccountID, - total: splitAmount, + ? buildOptimisticExpenseReport( + oneOnOneChatReport.reportID, + oneOnOneChatReport.policyID, + currentUserAccountID, + splitAmount, currency, - allBetas, - optimisticIOUReportID: optimisticExpenseReportID, + undefined, + undefined, + optimisticExpenseReportID, reportTransactions, - }) + ) : buildOptimisticIOUReport(currentUserAccountID, accountID, splitAmount, oneOnOneChatReport.reportID, currency); } else if (isOwnPolicyExpenseChat) { // Because of the Expense reports are stored as negative values, we subtract the total from the amount @@ -7431,7 +7401,6 @@ type SplitBillActionsParams = { transactionViolations: OnyxCollection; quickAction: OnyxEntry; policyRecentlyUsedCurrencies: string[]; - allBetas: OnyxEntry; }; /** @@ -7461,7 +7430,6 @@ function splitBill({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, policyRecentlyUsedTags, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); @@ -7491,7 +7459,6 @@ function splitBill({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); const parameters: SplitBillParams = { @@ -7553,7 +7520,6 @@ function splitBillAndOpenReport({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }: SplitBillActionsParams) { const parsedComment = getParsedComment(comment); const {splitData, splits, onyxData} = createSplitsAndOnyxData({ @@ -7582,7 +7548,6 @@ function splitBillAndOpenReport({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); const parameters: SplitBillParams = { @@ -7994,7 +7959,6 @@ function completeSplitBill( isASAPSubmitBetaEnabled: boolean, quickAction: OnyxEntry, transactionViolations: OnyxCollection, - allBetas: OnyxEntry, sessionEmail?: string, ) { if (!reportAction) { @@ -8115,7 +8079,7 @@ function completeSplitBill( } let oneOnOneIOUReport: OneOnOneIOUReport = oneOnOneChatReport?.iouReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oneOnOneChatReport.iouReportID}`] : null; - const shouldCreateNewOneOnOneIOUReport = shouldCreateNewMoneyRequestReportReportUtils(oneOnOneIOUReport, oneOnOneChatReport, false, allBetas); + const shouldCreateNewOneOnOneIOUReport = shouldCreateNewMoneyRequestReportReportUtils(oneOnOneIOUReport, oneOnOneChatReport, false); // Generate IDs upfront so we can pass them to buildOptimisticExpenseReport for formula computation const optimisticTransactionID = NumberUtils.rand64(); @@ -8132,16 +8096,17 @@ function completeSplitBill( ); oneOnOneIOUReport = isPolicyExpenseChat - ? buildOptimisticExpenseReport({ - chatReportID: oneOnOneChatReport?.reportID, - policyID: participant.policyID, - payeeAccountID: sessionAccountID, - total: splitAmount, - currency: currency ?? '', - allBetas, - optimisticIOUReportID: optimisticExpenseReportID, + ? buildOptimisticExpenseReport( + oneOnOneChatReport?.reportID, + participant.policyID, + sessionAccountID, + splitAmount, + currency ?? '', + undefined, + undefined, + optimisticExpenseReportID, reportTransactions, - }) + ) : buildOptimisticIOUReport(sessionAccountID, participant.accountID ?? CONST.DEFAULT_NUMBER_ID, splitAmount, oneOnOneChatReport?.reportID, currency ?? ''); } else if (isPolicyExpenseChat) { if (typeof oneOnOneIOUReport?.total === 'number') { @@ -8327,7 +8292,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } = distanceRequestInformation; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); @@ -8401,7 +8365,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); onyxData = splitOnyxData; @@ -8481,7 +8444,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, }); onyxData = moneyRequestOnyxData; @@ -9595,7 +9557,6 @@ function getReportFromHoldRequestsOnyxData({ recipient, policy, createdTimestamp, - allBetas, isApprovalFlow = false, }: { chatReport: OnyxTypes.Report; @@ -9603,7 +9564,6 @@ function getReportFromHoldRequestsOnyxData({ recipient: Participant; policy: OnyxEntry; createdTimestamp?: string; - allBetas: OnyxEntry; isApprovalFlow?: boolean; }): { optimisticHoldReportID: string; @@ -9633,18 +9593,18 @@ function getReportFromHoldRequestsOnyxData({ } const optimisticExpenseReport = isPolicyExpenseChat - ? buildOptimisticExpenseReport({ - chatReportID: chatReport.reportID, - policyID: chatReport.policyID ?? iouReport?.policyID, - payeeAccountID: recipient.accountID ?? 1, - total: holdAmount, - currency: iouReport?.currency ?? '', - allBetas, - nonReimbursableTotal: holdNonReimbursableAmount, - parentReportActionID: newParentReportActionID, + ? buildOptimisticExpenseReport( + chatReport.reportID, + chatReport.policyID ?? iouReport?.policyID, + recipient.accountID ?? 1, + holdAmount, + iouReport?.currency ?? '', + holdNonReimbursableAmount, + newParentReportActionID, + undefined, reportTransactions, createdTimestamp, - }) + ) : buildOptimisticIOUReport( iouReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID, iouReport?.managerID ?? CONST.DEFAULT_NUMBER_ID, @@ -9924,7 +9884,6 @@ function getPayMoneyRequestParams({ lastUsedPaymentMethod, existingB2BInvoiceReport, activePolicy, - allBetas, iouReportCurrentNextStepDeprecated, }: { initialChatReport: OnyxTypes.Report; @@ -9941,7 +9900,6 @@ function getPayMoneyRequestParams({ activePolicy?: OnyxEntry; currentUserAccountIDParam?: number; currentUserEmailParam?: string; - allBetas: OnyxEntry; introSelected?: OnyxEntry; iouReportCurrentNextStepDeprecated: OnyxEntry; }): PayMoneyRequestData { @@ -10232,7 +10190,7 @@ function getPayMoneyRequestParams({ let optimisticHoldActionID; let optimisticHoldReportExpenseActionIDs; if (!full) { - const holdReportOnyxData = getReportFromHoldRequestsOnyxData({chatReport, iouReport, recipient, policy: reportPolicy, allBetas}); + const holdReportOnyxData = getReportFromHoldRequestsOnyxData({chatReport, iouReport, recipient, policy: reportPolicy}); optimisticData.push(...holdReportOnyxData.optimisticData); successData.push(...holdReportOnyxData.successData); @@ -10440,7 +10398,6 @@ function approveMoneyRequest( hasViolations: boolean, isASAPSubmitBetaEnabled: boolean, expenseReportCurrentNextStepDeprecated: OnyxEntry, - allBetas: OnyxEntry, full?: boolean, ) { if (!expenseReport) { @@ -10625,7 +10582,6 @@ function approveMoneyRequest( policy, createdTimestamp: originalCreated, isApprovalFlow: true, - allBetas, }); optimisticData.push(...holdReportOnyxData.optimisticData); @@ -11711,7 +11667,6 @@ function payMoneyRequest( iouReport: OnyxEntry, introSelected: OnyxEntry, iouReportCurrentNextStepDeprecated: OnyxEntry, - allBetas: OnyxEntry, paymentPolicyID?: string, full = true, activePolicy?: OnyxEntry, @@ -11735,7 +11690,6 @@ function payMoneyRequest( paymentPolicyID, activePolicy, reportPolicy: policy, - allBetas, iouReportCurrentNextStepDeprecated, }); @@ -11761,7 +11715,6 @@ function payInvoice({ methodID, paymentMethod, activePolicy, - allBetas, invoiceReportCurrentNextStepDeprecated, }: PayInvoiceArgs) { const recipient = {accountID: invoiceReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID}; @@ -11794,7 +11747,6 @@ function payInvoice({ activePolicy, currentUserAccountIDParam, currentUserEmailParam, - allBetas, introSelected, }); @@ -12504,7 +12456,6 @@ function prepareRejectMoneyRequestData( reportID: string, comment: string, policy: OnyxEntry, - allBetas: OnyxEntry, options?: {sharedRejectedToReportID?: string}, shouldUseBulkAction?: boolean, ): RejectMoneyRequestData | undefined { @@ -12832,17 +12783,17 @@ function prepareRejectMoneyRequestData( // Pass transaction for formula computation (e.g., {report:startdate}) const reportTransactions: Record = {[transaction.transactionID]: transaction}; - const newExpenseReport = buildOptimisticExpenseReport({ - chatReportID: report.chatReportID, - policyID: report?.policyID, - payeeAccountID: report?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID, - total: transactionAmount, - currency: getCurrency(transaction), - allBetas, - nonReimbursableTotal: transactionAmount, - parentReportActionID: rejectedToReportID, + const newExpenseReport = buildOptimisticExpenseReport( + report.chatReportID, + report?.policyID, + report?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID, + transactionAmount, + getCurrency(transaction), + transactionAmount, + undefined, + rejectedToReportID, reportTransactions, - }); + ); const [, createdActionForExpenseReport, iouAction, ,] = buildOptimisticMoneyRequestEntities({ iouReport: newExpenseReport, type: CONST.IOU.REPORT_ACTION_TYPE.CREATE, @@ -13255,15 +13206,8 @@ function prepareRejectMoneyRequestData( return {optimisticData, successData, failureData, parameters, urlToNavigateBack: urlToNavigateBack as Route}; } -function rejectMoneyRequest( - transactionID: string, - reportID: string, - comment: string, - policy: OnyxEntry, - allBetas: OnyxEntry, - options?: {sharedRejectedToReportID?: string}, -): Route | undefined { - const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, allBetas, options); +function rejectMoneyRequest(transactionID: string, reportID: string, comment: string, policy: OnyxEntry, options?: {sharedRejectedToReportID?: string}): Route | undefined { + const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, options); if (!data) { return; } @@ -13689,7 +13633,6 @@ function updateSplitTransactions({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, iouReportNextStep, }: UpdateSplitTransactionsParams) { const transactionReport = getReportOrDraftReport(transactionData?.reportID); @@ -13830,7 +13773,6 @@ function updateSplitTransactions({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, } as MoneyRequestInformationParams; if (isReverseSplitOperation) { @@ -13874,7 +13816,6 @@ function updateSplitTransactions({ quickAction, shouldGenerateTransactionThreadReport: !isReverseSplitOperation, policyRecentlyUsedCurrencies, - allBetas, }); let updateMoneyRequestParamsOnyxData: OnyxData = {}; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 637f4e66b3643..aa380cd341839 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -186,7 +186,6 @@ import SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewRoomForm'; import type { BankAccountList, - Beta, IntroSelected, InvitedEmailsToAccountIDs, NewGroupChatDraft, @@ -2883,12 +2882,11 @@ function buildNewReportOptimisticData( reportPreviewReportActionID: string, hasViolationsParam: boolean, isASAPSubmitBetaEnabled: boolean, - allBetas: OnyxEntry, ) { const {accountID, login, email} = creatorPersonalDetails; const timeOfCreation = DateUtils.getDBTime(); const parentReport = getPolicyExpenseChat(accountID, policy?.id); - const optimisticReportData = buildOptimisticEmptyReport(reportID, accountID, parentReport, reportPreviewReportActionID, policy, timeOfCreation, allBetas); + const optimisticReportData = buildOptimisticEmptyReport(reportID, accountID, parentReport, reportPreviewReportActionID, policy, timeOfCreation); const optimisticNextStep = buildOptimisticNextStep({ report: optimisticReportData, @@ -3112,7 +3110,6 @@ function createNewReport( hasViolationsParam: boolean, isASAPSubmitBetaEnabled: boolean, policy: OnyxEntry, - allBetas: OnyxEntry, shouldNotifyNewAction = false, shouldDismissEmptyReportsConfirmation?: boolean, ) { @@ -3128,7 +3125,6 @@ function createNewReport( reportPreviewReportActionID, hasViolationsParam, isASAPSubmitBetaEnabled, - allBetas, ); if (shouldDismissEmptyReportsConfirmation) { diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 4af78b337b1f0..a9896218641df 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -46,7 +46,7 @@ import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import {FILTER_KEYS} from '@src/types/form/SearchAdvancedFiltersForm'; import type {SearchAdvancedFiltersForm} from '@src/types/form/SearchAdvancedFiltersForm'; -import type {Beta, ExportTemplate, LastPaymentMethod, LastPaymentMethodType, Policy, Report, ReportAction, ReportActions, Transaction} from '@src/types/onyx'; +import type {ExportTemplate, LastPaymentMethod, LastPaymentMethodType, Policy, Report, ReportAction, ReportActions, Transaction} from '@src/types/onyx'; import type {PaymentInformation} from '@src/types/onyx/LastPaymentMethod'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type {OnyxData} from '@src/types/onyx/Request'; @@ -763,7 +763,7 @@ function deleteMoneyRequestOnSearch(hash: number, transactionIDList: string[]) { } } -function rejectMoneyRequestInBulk(reportID: string, comment: string, policy: OnyxEntry, transactionIDs: string[], allBetas: OnyxEntry, hash?: number) { +function rejectMoneyRequestInBulk(reportID: string, comment: string, policy: OnyxEntry, transactionIDs: string[], hash?: number) { const optimisticData: Array> = []; const finallyData: Array> = []; const successData: RejectMoneyRequestData['successData'] = []; @@ -781,7 +781,7 @@ function rejectMoneyRequestInBulk(reportID: string, comment: string, policy: Ony } > = {}; for (const transactionID of transactionIDs) { - const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, allBetas, undefined, true); + const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, undefined, true); if (data) { optimisticData.push(...data.optimisticData); successData.push(...data.successData); @@ -811,7 +811,6 @@ function rejectMoneyRequestsOnSearch( comment: string, allPolicies: OnyxCollection, allReports: OnyxCollection, - allBetas: OnyxEntry, ) { const transactionIDs = Object.keys(selectedTransactions); @@ -844,12 +843,12 @@ function rejectMoneyRequestsOnSearch( const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; const isPolicyDelayedSubmissionEnabled = policy ? isDelayedSubmissionEnabled(policy) : false; if (isPolicyDelayedSubmissionEnabled && areAllExpensesSelected) { - rejectMoneyRequestInBulk(reportID, comment, policy, selectedTransactionIDs, allBetas, hash); + rejectMoneyRequestInBulk(reportID, comment, policy, selectedTransactionIDs, hash); } else { // Share a single destination ID across all rejections from the same source report const sharedRejectedToReportID = generateReportID(); for (const transactionID of selectedTransactionIDs) { - rejectMoneyRequest(transactionID, reportID, comment, policy, allBetas, {sharedRejectedToReportID}); + rejectMoneyRequest(transactionID, reportID, comment, policy, {sharedRejectedToReportID}); } } if (isSingleReport && areAllExpensesSelected && !isPolicyDelayedSubmissionEnabled) { diff --git a/src/pages/NewReportWorkspaceSelectionPage.tsx b/src/pages/NewReportWorkspaceSelectionPage.tsx index 8d9cbde58422d..610d2aaa034be 100644 --- a/src/pages/NewReportWorkspaceSelectionPage.tsx +++ b/src/pages/NewReportWorkspaceSelectionPage.tsx @@ -68,7 +68,7 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, accountID ?? CONST.DEFAULT_NUMBER_ID, email ?? ''); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [hasDismissedEmptyReportsConfirmation] = useOnyx(ONYXKEYS.NVP_EMPTY_REPORTS_CONFIRMATION_DISMISSED, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -122,7 +122,6 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag isASAPSubmitBetaEnabled, hasViolations, policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`], - allBetas, false, shouldDismissEmptyReportsConfirmation, ); @@ -171,7 +170,6 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag navigateToNewReport, allReportNextSteps, backTo, - allBetas, allTransactions, activePolicyID, clearSelectedTransactions, diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index f1332e5c58412..87b8cb9f7d637 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -172,7 +172,7 @@ function EmptySearchViewContent({ const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector, canBeMissing: true}); const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, accountID ?? CONST.DEFAULT_NUMBER_ID, ''); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const [hasTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { canBeMissing: true, selector: hasTransactionsSelector, @@ -215,7 +215,6 @@ function EmptySearchViewContent({ hasViolations, isASAPSubmitBetaEnabled, defaultChatEnabledPolicy, - allBetas, false, shouldDismissEmptyReportsConfirmation, ); diff --git a/src/pages/Search/SearchRejectReasonPage.tsx b/src/pages/Search/SearchRejectReasonPage.tsx index 4960931196b81..770fa6af237cb 100644 --- a/src/pages/Search/SearchRejectReasonPage.tsx +++ b/src/pages/Search/SearchRejectReasonPage.tsx @@ -24,7 +24,6 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { const {reportID} = route.params ?? {}; const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: true}); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); // When coming from the report view, selectedTransactions is empty, build it from selectedTransactionIDs const selectedTransactionsForReject = useMemo(() => { @@ -45,7 +44,7 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { return; } - const urlToNavigateBack = rejectMoneyRequestsOnSearch(context.currentSearchHash, selectedTransactionsForReject, comment, allPolicies, allReports, allBetas); + const urlToNavigateBack = rejectMoneyRequestsOnSearch(context.currentSearchHash, selectedTransactionsForReject, comment, allPolicies, allReports); if (route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_REJECT_TRANSACTIONS) { context.clearSelectedTransactions(true); } else { @@ -56,7 +55,7 @@ function SearchRejectReasonPage({route}: SearchRejectReasonPageProps) { Navigation.isNavigationReady().then(() => Navigation.goBack(urlToNavigateBack as Route)); } }, - [context, allPolicies, allReports, route.name, selectedTransactionsForReject, allBetas, isDelegateAccessRestricted, showDelegateNoAccessModal], + [context, allPolicies, allReports, route.name, selectedTransactionsForReject, isDelegateAccessRestricted, showDelegateNoAccessModal], ); const validate = useCallback((values: FormOnyxValues) => { diff --git a/src/pages/Search/SearchTransactionsChangeReport.tsx b/src/pages/Search/SearchTransactionsChangeReport.tsx index fb0ae95700423..8744ffcf203eb 100644 --- a/src/pages/Search/SearchTransactionsChangeReport.tsx +++ b/src/pages/Search/SearchTransactionsChangeReport.tsx @@ -35,7 +35,6 @@ function SearchTransactionsChangeReport() { const hasPerDiemTransactions = useHasPerDiemTransactions(selectedTransactionsKeys); const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses(hasPerDiemTransactions); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true}); const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); @@ -75,15 +74,7 @@ function SearchTransactionsChangeReport() { }, [selectedTransactions, selectedTransactionsKeys]); const createReportForPolicy = (shouldDismissEmptyReportsConfirmation?: boolean) => { - const optimisticReport = createNewReport( - currentUserPersonalDetails, - hasViolations, - isASAPSubmitBetaEnabled, - policyForMovingExpenses, - allBetas, - false, - shouldDismissEmptyReportsConfirmation, - ); + const optimisticReport = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForMovingExpenses, false, shouldDismissEmptyReportsConfirmation); const reportNextStep = allReportNextSteps?.[`${ONYXKEYS.COLLECTION.NEXT_STEP}${optimisticReport.reportID}`]; setNavigationActionToMicrotaskQueue(() => { changeTransactionsReport({ diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 6b6b65537e257..3705b202264d4 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -69,7 +69,7 @@ function SubmitDetailsPage({ const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const personalPolicy = usePersonalPolicy(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -156,7 +156,6 @@ function SubmitDetailsPage({ activePolicyID, introSelected, quickAction, - allBetas, }); } else { requestMoney({ @@ -190,7 +189,6 @@ function SubmitDetailsPage({ currentUserEmailParam: currentUserPersonalDetails.login ?? '', transactionViolations, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, }); } diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 73237944997e4..7bdade046f45b 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -181,7 +181,6 @@ function AttachmentPickerWithMenuItems({ () => hasEmptyReportsForPolicy(reportSummaries, report?.policyID, accountID) && hasDismissedEmptyReportsConfirmation !== true, [accountID, hasDismissedEmptyReportsConfirmation, report?.policyID, reportSummaries], ); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const selectOption = useCallback( (onSelected: () => void, shouldRestrictAction: boolean) => { @@ -199,7 +198,7 @@ function AttachmentPickerWithMenuItems({ policyID: report?.policyID, policyName: policy?.name ?? '', onConfirm: (shouldDismissEmptyReportsConfirmation) => - selectOption(() => createNewReport(currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, allBetas, true, shouldDismissEmptyReportsConfirmation), true), + selectOption(() => createNewReport(currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, true, shouldDismissEmptyReportsConfirmation), true), }); const openCreateReportConfirmationRef = useRef(openCreateReportConfirmation); @@ -209,9 +208,9 @@ function AttachmentPickerWithMenuItems({ if (shouldShowEmptyReportConfirmation) { openCreateReportConfirmationRef.current(); } else { - createNewReport(currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, allBetas, true, false); + createNewReport(currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, true, false); } - }, [currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, shouldShowEmptyReportConfirmation, allBetas]); + }, [currentUserPersonalDetails, isASAPSubmitBetaEnabled, hasViolations, policy, shouldShowEmptyReportConfirmation]); const teacherUnitePolicyID = isProduction ? CONST.TEACHERS_UNITE.PROD_POLICY_ID : CONST.TEACHERS_UNITE.TEST_POLICY_ID; const isTeachersUniteReport = report?.policyID === teacherUnitePolicyID; @@ -290,7 +289,7 @@ function AttachmentPickerWithMenuItems({ ], }; - const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], allBetas, isReportArchived, isRestrictedToPreferredPolicy).map( + const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? [], isReportArchived, isRestrictedToPreferredPolicy).map( (option) => options[option], ); @@ -308,7 +307,6 @@ function AttachmentPickerWithMenuItems({ showDelegateNoAccessModal, translate, icons, - allBetas, ]); const createReportOption: PopoverMenuItem[] = useMemo(() => { diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 11b8e115028cb..ff5d573c478b7 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -158,7 +158,6 @@ function ReportActionCompose({ const [initialModalState] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true}); const [newParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`, {canBeMissing: true}); const [draftComment] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const shouldFocusComposerOnScreenFocus = shouldFocusInputOnScreenFocus || !!draftComment; @@ -246,11 +245,11 @@ function ReportActionCompose({ const shouldDisplayDualDropZone = useMemo(() => { const parentReport = getParentReport(report); const isSettledOrApproved = isSettled(report) || isSettled(parentReport) || isReportApproved({report}) || isReportApproved({report: parentReport}); - const hasMoneyRequestOptions = !!temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs, allBetas, isReportArchived, isRestrictedToPreferredPolicy).length; + const hasMoneyRequestOptions = !!temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs, isReportArchived, isRestrictedToPreferredPolicy).length; const canModifyReceipt = shouldAddOrReplaceReceipt && !isSettledOrApproved; const isRoomOrGroupChat = isChatRoom(report) || isGroupChat(report); return !isRoomOrGroupChat && (canModifyReceipt || hasMoneyRequestOptions) && !isInvoiceReport(report); - }, [shouldAddOrReplaceReceipt, report, reportParticipantIDs, policy, isReportArchived, isRestrictedToPreferredPolicy, allBetas]); + }, [shouldAddOrReplaceReceipt, report, reportParticipantIDs, policy, isReportArchived, isRestrictedToPreferredPolicy]); // Placeholder to display in the chat input. const inputPlaceholder = useMemo(() => { diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index ea163ed5ef081..55a9eba5b6ccb 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -118,7 +118,6 @@ function ReportActionItemParentAction({ const ancestors = useAncestors(report, shouldExcludeAncestorReportAction); const {isOffline} = useNetwork(); const {isInNarrowPaneModal} = useResponsiveLayout(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const ancestorReportNameValuePairsSelector = useCallback( (allReportNameValuePairs: OnyxCollection) => { @@ -179,14 +178,14 @@ function ReportActionItemParentAction({ {shouldDisplayThreadDivider && ( )} navigateToLinkedReportAction(ancestor, isInNarrowPaneModal, canUserPerformWriteAction, isOffline) : undefined } diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 12f06e9c040cc..a761fe442e55c 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -176,7 +176,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const prevIsFocused = usePrevious(isFocused); const isReportArchived = useReportIsArchived(quickActionReport?.reportID); const {isOffline} = useNetwork(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const isBlockedFromSpotnanaTravel = Permissions.isBetaEnabled(CONST.BETAS.PREVENT_SPOTNANA_TRAVEL, allBetas); const {isBetaEnabled} = usePermissions(); const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: accountPrimaryLoginSelector, canBeMissing: true}); @@ -239,7 +239,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref hasViolations, isASAPSubmitBetaEnabled, defaultChatEnabledPolicy, - allBetas, false, shouldDismissEmptyReportsConfirmation, ); @@ -252,7 +251,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref ); }); }, - [currentUserPersonalDetails, hasViolations, defaultChatEnabledPolicy, isASAPSubmitBetaEnabled, isReportInSearch, allBetas], + [currentUserPersonalDetails, hasViolations, defaultChatEnabledPolicy, isASAPSubmitBetaEnabled, isReportInSearch], ); const {openCreateReportConfirmation: openFabCreateReportConfirmation, CreateReportConfirmationModal: FabCreateReportConfirmationModal} = useCreateEmptyReportConfirmation({ @@ -444,7 +443,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref }; if (quickAction?.action && quickActionReport) { - if (!isQuickActionAllowed(quickAction, quickActionReport, quickActionPolicy, isReportArchived, allBetas, isRestrictedToPreferredPolicy)) { + if (!isQuickActionAllowed(quickAction, quickActionReport, quickActionPolicy, isReportArchived, isRestrictedToPreferredPolicy)) { return []; } const onSelected = () => { @@ -535,7 +534,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref showDelegateNoAccessModal, reportID, allTransactionDrafts, - allBetas, ]); const isTravelEnabled = useMemo(() => { diff --git a/src/pages/iou/RejectReasonPage.tsx b/src/pages/iou/RejectReasonPage.tsx index 93bbe580a28bf..f70f5beacab1a 100644 --- a/src/pages/iou/RejectReasonPage.tsx +++ b/src/pages/iou/RejectReasonPage.tsx @@ -31,7 +31,6 @@ function RejectReasonPage({route}: RejectReasonPageProps) { const {removeTransaction} = useSearchContext(); const [reportPolicyID] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(reportID)}`, {canBeMissing: false, selector: getReportPolicyID}); const policy = usePolicy(reportPolicyID); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const {superWideRHPRouteKeys} = useContext(WideRHPContext); const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); @@ -41,7 +40,7 @@ function RejectReasonPage({route}: RejectReasonPageProps) { return; } - const urlToNavigateBack = rejectMoneyRequest(transactionID, reportID, values.comment, policy, allBetas); + const urlToNavigateBack = rejectMoneyRequest(transactionID, reportID, values.comment, policy); removeTransaction(transactionID); // If the super wide rhp is not opened, dismiss the entire modal. if (superWideRHPRouteKeys.length > 0) { diff --git a/src/pages/iou/SplitBillDetailsPage.tsx b/src/pages/iou/SplitBillDetailsPage.tsx index 1ddde7fcde8ec..1929efc8e2b1a 100644 --- a/src/pages/iou/SplitBillDetailsPage.tsx +++ b/src/pages/iou/SplitBillDetailsPage.tsx @@ -41,7 +41,6 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag const {translate} = useLocalize(); const theme = useTheme(); const {isBetaEnabled} = usePermissions(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const icons = useMemoizedLazyExpensifyIcons(['ReceiptScan']); const reportID = report?.reportID; @@ -102,10 +101,9 @@ function SplitBillDetailsPage({route, report, reportAction}: SplitBillDetailsPag isASAPSubmitBetaEnabled, quickAction, transactionViolations, - allBetas, session?.email, ); - }, [reportID, reportAction, draftTransaction, session?.accountID, session?.email, isASAPSubmitBetaEnabled, quickAction, transactionViolations, allBetas]); + }, [reportID, reportAction, draftTransaction, session?.accountID, session?.email, isASAPSubmitBetaEnabled, quickAction, transactionViolations]); return ( diff --git a/src/pages/iou/SplitExpensePage.tsx b/src/pages/iou/SplitExpensePage.tsx index a0268d7428398..163a659b5b625 100644 --- a/src/pages/iou/SplitExpensePage.tsx +++ b/src/pages/iou/SplitExpensePage.tsx @@ -84,7 +84,6 @@ function SplitExpensePage({route}: SplitExpensePageProps) { const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getNonEmptyStringOnyxID(expenseReport?.policyID)}`, {canBeMissing: true}); const [expenseReportPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getNonEmptyStringOnyxID(expenseReport?.policyID)}`, {canBeMissing: true}); const allTransactions = useAllTransactions(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`]; @@ -224,7 +223,6 @@ function SplitExpensePage({route}: SplitExpensePageProps) { currentUserPersonalDetails, transactionViolations, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, iouReportNextStep, }); diff --git a/src/pages/iou/request/step/IOURequestEditReport.tsx b/src/pages/iou/request/step/IOURequestEditReport.tsx index 74cb8716d0987..ea6bd74d7e93b 100644 --- a/src/pages/iou/request/step/IOURequestEditReport.tsx +++ b/src/pages/iou/request/step/IOURequestEditReport.tsx @@ -47,7 +47,6 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) { const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const selectedReportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${selectedReport?.policyID}`]; - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const hasPerDiemTransactions = useHasPerDiemTransactions(selectedTransactionIDs); const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses(hasPerDiemTransactions); @@ -107,15 +106,7 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) { } const policyForNewReport = hasPerDiemTransactions ? selectedReportPolicy : policyForMovingExpenses; - const optimisticReport = createNewReport( - currentUserPersonalDetails, - hasViolations, - isASAPSubmitBetaEnabled, - policyForNewReport, - allBetas, - false, - shouldDismissEmptyReportsConfirmation, - ); + const optimisticReport = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForNewReport, false, shouldDismissEmptyReportsConfirmation); selectReport({value: optimisticReport.reportID}, optimisticReport); }; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index f05f4155fac40..2049e518ef147 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -88,7 +88,6 @@ function IOURequestStepAmount({ const policyID = isTrackExpense ? policyForMovingExpensesID : report?.policyID; const isReportArchived = useReportIsArchived(report?.reportID); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true}); const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true}); const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID)}`, {canBeMissing: true}); @@ -251,7 +250,6 @@ function IOURequestStepAmount({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); return; } @@ -276,7 +274,6 @@ function IOURequestStepAmount({ introSelected, activePolicyID, quickAction, - allBetas, }); return; } diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index cc0c48d6e5e28..b8e6f473c867e 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -273,7 +273,6 @@ function IOURequestStepConfirmation({ const isCategorizingTrackExpense = action === CONST.IOU.ACTION.CATEGORIZE; const isMovingTransactionFromTrackExpense = isMovingTransactionFromTrackExpenseIOUUtils(action); const isTestTransaction = transaction?.participants?.some((participant) => isSelectedManagerMcTest(participant.login)); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const gpsRequired = transaction?.amount === 0 && iouType !== CONST.IOU.TYPE.SPLIT && Object.values(receiptFiles).length && !isTestTransaction; const [isConfirmed, setIsConfirmed] = useState(false); @@ -633,7 +632,6 @@ function IOURequestStepConfirmation({ currentUserEmailParam: currentUserPersonalDetails.email ?? '', transactionViolations, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, }); existingIOUReport = iouReport; @@ -668,7 +666,6 @@ function IOURequestStepConfirmation({ isViewTourTaskParentReportArchived, hasOutstandingChildTask, parentReportAction, - allBetas, isTimeRequest, ], ); @@ -716,7 +713,6 @@ function IOURequestStepConfirmation({ currentUserEmailParam: currentUserPersonalDetails.login ?? '', hasViolations, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, quickAction, }); }, @@ -733,7 +729,6 @@ function IOURequestStepConfirmation({ isASAPSubmitBetaEnabled, hasViolations, policyRecentlyUsedCurrencies, - allBetas, quickAction, ], ); @@ -801,7 +796,6 @@ function IOURequestStepConfirmation({ introSelected, activePolicyID, quickAction, - allBetas, }); } }, @@ -826,7 +820,6 @@ function IOURequestStepConfirmation({ introSelected, activePolicyID, quickAction, - allBetas, ], ); @@ -876,7 +869,6 @@ function IOURequestStepConfirmation({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); }, [ @@ -902,7 +894,6 @@ function IOURequestStepConfirmation({ transactionViolations, quickAction, policyRecentlyUsedCurrencies, - allBetas, ], ); @@ -1004,7 +995,6 @@ function IOURequestStepConfirmation({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); } return; @@ -1036,7 +1026,6 @@ function IOURequestStepConfirmation({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); } return; @@ -1176,7 +1165,6 @@ function IOURequestStepConfirmation({ userLocation, submitPerDiemExpense, policyRecentlyUsedCurrencies, - allBetas, reportID, ], ); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 453e9a66ef71d..93c5d2b9f55d8 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -144,7 +144,6 @@ function IOURequestStepDistance({ const isCreatingNewRequest = !(backTo || isEditing); const [recentWaypoints, {status: recentWaypointsStatus}] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS, {canBeMissing: true}); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const iouRequestType = getRequestType(transaction); const customUnitRateID = getRateID(transaction); // eslint-disable-next-line rulesdir/no-negated-variables @@ -311,7 +310,6 @@ function IOURequestStepDistance({ introSelected, activePolicyID, privateIsArchived: reportNameValuePairs?.private_isArchived, - allBetas, }); }, [ transaction, @@ -335,14 +333,12 @@ function IOURequestStepDistance({ isASAPSubmitBetaEnabled, transactionViolations, quickAction, - allBetas, policyRecentlyUsedCurrencies, customUnitRateID, introSelected, activePolicyID, personalPolicy?.autoReporting, reportID, - allBetas, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx index a5cca5e6ac376..44374463af6ba 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx @@ -82,7 +82,6 @@ function IOURequestStepDistanceManual({ const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, {canBeMissing: true}); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID)}`, {canBeMissing: true}); @@ -203,7 +202,6 @@ function IOURequestStepDistanceManual({ introSelected, activePolicyID, privateIsArchived: reportNameValuePairs?.private_isArchived, - allBetas, }); }, [ @@ -231,7 +229,6 @@ function IOURequestStepDistanceManual({ backToReport, transactionViolations, quickAction, - allBetas, policyRecentlyUsedCurrencies, customUnitRateID, introSelected, @@ -239,7 +236,6 @@ function IOURequestStepDistanceManual({ defaultExpensePolicy, personalPolicy?.autoReporting, reportID, - allBetas, ], ); diff --git a/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx b/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx index a317d5d9f7e85..e9d06da84fec9 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceMap.tsx @@ -144,7 +144,7 @@ function IOURequestStepDistanceMap({ const customUnitRateID = getRateID(transaction); // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useShowNotFoundPageInIOUStep(action, iouType, reportActionID, report, transaction); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); + const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); @@ -310,7 +310,6 @@ function IOURequestStepDistanceMap({ introSelected, activePolicyID, privateIsArchived: reportNameValuePairs?.private_isArchived, - allBetas, }); }, [ transaction, @@ -340,7 +339,6 @@ function IOURequestStepDistanceMap({ activePolicyID, personalPolicy?.autoReporting, reportID, - allBetas, ]); const getError = () => { diff --git a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx index 6fb6d39f8ad3e..2e7cb49d6e8c2 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx @@ -81,7 +81,6 @@ function IOURequestStepDistanceOdometer({ const [formError, setFormError] = useState(''); // Key to force TextInput remount when resetting state after tab switch const [inputKey, setInputKey] = useState(0); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); // Track initial values for DiscardChangesConfirmation const initialStartReadingRef = useRef(''); @@ -417,7 +416,6 @@ function IOURequestStepDistanceOdometer({ introSelected, activePolicyID, quickAction, - allBetas, }); return; } @@ -448,7 +446,6 @@ function IOURequestStepDistanceOdometer({ transactionViolations, quickAction, policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [], - allBetas, }); return; } diff --git a/src/pages/iou/request/step/IOURequestStepReport.tsx b/src/pages/iou/request/step/IOURequestStepReport.tsx index bdc61d4743537..fe57f6fe497af 100644 --- a/src/pages/iou/request/step/IOURequestStepReport.tsx +++ b/src/pages/iou/request/step/IOURequestStepReport.tsx @@ -54,7 +54,6 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { const isCreateReport = action === CONST.IOU.ACTION.CREATE; const isFromGlobalCreate = !!transaction?.isFromGlobalCreate; const {isBetaEnabled} = usePermissions(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const session = useSession(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -191,15 +190,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) { } const policyForNewReport = isPerDiemTransaction && perDiemOriginalPolicy ? perDiemOriginalPolicy : policyForMovingExpenses; - const optimisticReport = createNewReport( - currentUserPersonalDetails, - hasViolations, - isASAPSubmitBetaEnabled, - policyForNewReport, - allBetas, - false, - shouldDismissEmptyReportsConfirmation, - ); + const optimisticReport = createNewReport(currentUserPersonalDetails, hasViolations, isASAPSubmitBetaEnabled, policyForNewReport, false, shouldDismissEmptyReportsConfirmation); handleRegularReportSelection({value: optimisticReport.reportID}, optimisticReport); }; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 4d22406aeaf63..bac2bb429b385 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -96,7 +96,6 @@ function IOURequestStepScan({ const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); const [receiptFiles, setReceiptFiles] = useState([]); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const isArchived = isArchivedReport(reportNameValuePairs); const policy = usePolicy(report?.policyID); const personalPolicy = usePersonalPolicy(); @@ -295,7 +294,6 @@ function IOURequestStepScan({ files, isTestTransaction, locationPermissionGranted, - allBetas, }); }, [ @@ -328,7 +326,6 @@ function IOURequestStepScan({ policyRecentlyUsedCurrencies, introSelected, activePolicyID, - allBetas, ], ); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 208f7592fae6b..d87664bd01a3e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -92,7 +92,6 @@ function IOURequestStepScan({ const [isQueriedPermissionState, setIsQueriedPermissionState] = useState(false); const [shouldShowMultiScanEducationalPopup, setShouldShowMultiScanEducationalPopup] = useState(false); const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES, {canBeMissing: true}); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const getScreenshotTimeoutRef = useRef(null); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, {canBeMissing: true}); @@ -348,7 +347,6 @@ function IOURequestStepScan({ files, isTestTransaction, locationPermissionGranted, - allBetas, }); }, [ @@ -381,7 +379,6 @@ function IOURequestStepScan({ transactionViolations, introSelected, activePolicyID, - allBetas, ], ); diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index bc9207819b011..e7425b90abc58 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -22,7 +22,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import type {Beta, Report} from '@src/types/onyx'; +import type {Report} from '@src/types/onyx'; import type {PolicyFeatureName} from '@src/types/onyx/Policy'; import type Policy from '@src/types/onyx/Policy'; import callOrReturn from '@src/types/utils/callOrReturn'; @@ -37,7 +37,6 @@ const ACCESS_VARIANTS = { login: string, report: OnyxEntry, allPolicies: NonNullable> | null, - allBetas: OnyxEntry, iouType?: IOUType, isReportArchived?: boolean, isRestrictedToPreferredPolicy?: boolean, @@ -46,7 +45,7 @@ const ACCESS_VARIANTS = { isValidMoneyRequestType(iouType) && // Allow the user to submit the expense if we are submitting the expense in global menu or the report can create the expense - (isEmptyObject(report?.reportID) || canCreateRequest(report, policy, iouType, isReportArchived, allBetas, isRestrictedToPreferredPolicy)) && + (isEmptyObject(report?.reportID) || canCreateRequest(report, policy, iouType, isReportArchived, isRestrictedToPreferredPolicy)) && (iouType !== CONST.IOU.TYPE.INVOICE || canSendInvoice(allPolicies, login)), } as const satisfies Record< string, @@ -55,7 +54,6 @@ const ACCESS_VARIANTS = { login: string, report: Report, allPolicies: NonNullable> | null, - allBetas?: OnyxEntry, iouType?: IOUType, isArchivedReport?: boolean, isRestrictedToPreferredPolicy?: boolean, @@ -150,7 +148,6 @@ function AccessOrNotFoundWrapper({ const [isLoadingReportData = true] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {canBeMissing: true}); const {login = ''} = useCurrentUserPersonalDetails(); const {isRestrictedToPreferredPolicy} = usePreferredPolicy(); - const [allBetas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const isPolicyIDInRoute = !!policyID?.length; const isMoneyRequest = !!iouType && isValidMoneyRequestType(iouType); const isFromGlobalCreate = !!reportID && isEmptyObject(report?.reportID); @@ -177,9 +174,9 @@ function AccessOrNotFoundWrapper({ const isPageAccessible = accessVariants.reduce((acc, variant) => { const accessFunction = ACCESS_VARIANTS[variant]; if (variant === CONST.IOU.ACCESS_VARIANTS.CREATE) { - return acc && accessFunction(policy, login, report, allPolicies ?? null, allBetas, iouType, isReportArchived, isRestrictedToPreferredPolicy); + return acc && accessFunction(policy, login, report, allPolicies ?? null, iouType, isReportArchived, isRestrictedToPreferredPolicy); } - return acc && accessFunction(policy, login, report, allPolicies ?? null, allBetas, iouType, isReportArchived); + return acc && accessFunction(policy, login, report, allPolicies ?? null, iouType, isReportArchived); }, true); const isPolicyNotAccessible = !isPolicyAccessible(policy, login); diff --git a/tests/actions/IOU/MoneyRequestTest.ts b/tests/actions/IOU/MoneyRequestTest.ts index c769b8e1d2f43..9ec270de68557 100644 --- a/tests/actions/IOU/MoneyRequestTest.ts +++ b/tests/actions/IOU/MoneyRequestTest.ts @@ -81,7 +81,6 @@ describe('MoneyRequest', () => { files: [fakeReceiptFile], participant: {accountID: 222, login: 'test@test.com'}, quickAction: fakeQuickAction, - allBetas: [CONST.BETAS.ALL], }; afterEach(() => { @@ -285,7 +284,6 @@ describe('MoneyRequest', () => { quickAction: fakeQuickAction, files: [fakeReceiptFile], shouldGenerateTransactionThreadReport: false, - allBetas: [CONST.BETAS.ALL], }; beforeEach(async () => { @@ -516,7 +514,6 @@ describe('MoneyRequest', () => { currentUserEmailParam: baseParams.currentUserLogin, quickAction: baseParams.quickAction, shouldHandleNavigation: true, - allBetas: baseParams.allBetas, }); // Should not call request money inside createTransaction function expect(IOU.requestMoney).not.toHaveBeenCalled(); @@ -710,7 +707,6 @@ describe('MoneyRequest', () => { setDistanceRequestData: jest.fn(), translate: jest.fn().mockReturnValue('Pending...'), quickAction: fakeQuickAction, - allBetas: [CONST.BETAS.ALL], }; const splitShares: SplitShares = { [firstSplitParticipantID]: { @@ -809,7 +805,6 @@ describe('MoneyRequest', () => { currentUserAccountIDParam: baseParams.currentUserAccountID, currentUserEmailParam: baseParams.currentUserLogin, quickAction: baseParams.quickAction, - allBetas: baseParams.allBetas, }); // The function must return after trackExpense and not call createDistanceRequest @@ -871,7 +866,6 @@ describe('MoneyRequest', () => { currentUserAccountIDParam: baseParams.currentUserAccountID, currentUserEmailParam: baseParams.currentUserLogin, quickAction: baseParams.quickAction, - allBetas: baseParams.allBetas, }); }); @@ -909,7 +903,6 @@ describe('MoneyRequest', () => { transactionViolations: baseParams.transactionViolations, quickAction: baseParams.quickAction, policyRecentlyUsedCurrencies: [], - allBetas: baseParams.allBetas, }), ); }); diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 467ef75f94e86..420e0fa81b04c 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -519,7 +519,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); await mockFetch?.resume?.(); @@ -620,7 +619,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); await mockFetch?.resume?.(); @@ -704,7 +702,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -757,7 +754,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -836,7 +832,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -889,7 +884,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -1137,7 +1131,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); return waitForBatchedUpdates() @@ -1393,7 +1386,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); return waitForBatchedUpdates(); @@ -1622,7 +1614,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -1787,7 +1778,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); return ( @@ -2190,7 +2180,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); mockFetch?.resume?.(); @@ -2256,7 +2245,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -2299,7 +2287,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); expect(notifyNewAction).toHaveBeenCalledTimes(0); @@ -2327,7 +2314,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); expect(Navigation.setNavigationActionToMicrotaskQueue).toHaveBeenCalledTimes(1); @@ -2372,7 +2358,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, policyRecentlyUsedCurrencies: [], currentUserEmailParam: 'existing@example.com', - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -2412,7 +2397,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -2478,7 +2462,6 @@ describe('actions/IOU', () => { currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.login ?? '', policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); waitForBatchedUpdates(); @@ -2516,7 +2499,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); expect(notifyNewAction).toHaveBeenCalledTimes(0); }); @@ -2538,7 +2520,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); expect(notifyNewAction).toHaveBeenCalledTimes(1); }); @@ -2562,7 +2543,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); expect(await getOnyxValue(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE)).toHaveProperty('isFirstQuickAction', true); @@ -2583,7 +2563,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: {action: CONST.QUICK_ACTIONS.SEND_MONEY, chatReportID: '456'}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); expect(await getOnyxValue(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE)).toMatchObject({ @@ -2615,7 +2594,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: initialCurrencies, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -2666,7 +2644,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); waitForBatchedUpdates(); @@ -2726,7 +2703,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); waitForBatchedUpdates(); @@ -2916,7 +2892,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }, ); @@ -3254,7 +3229,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3302,7 +3276,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3324,7 +3297,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: {action: CONST.QUICK_ACTIONS.SEND_MONEY, chatReportID: '456'}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); await waitForBatchedUpdates(); @@ -3353,7 +3325,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: initialCurrencies, - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3387,7 +3358,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3407,7 +3377,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3466,7 +3435,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3515,7 +3483,6 @@ describe('actions/IOU', () => { transactionViolations: {}, quickAction: undefined, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], policyRecentlyUsedTags: undefined, }); @@ -3576,7 +3543,6 @@ describe('actions/IOU', () => { policyRecentlyUsedTags, quickAction: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], }); waitForBatchedUpdates(); @@ -3645,7 +3611,7 @@ describe('actions/IOU', () => { expect(iouAction).toBeTruthy(); // Complete this split bill without changing the description - completeSplitBill(reportID, iouAction, updatedSplitTransaction, RORY_ACCOUNT_ID, false, undefined, {}, [CONST.BETAS.ALL], RORY_EMAIL); + completeSplitBill(reportID, iouAction, updatedSplitTransaction, RORY_ACCOUNT_ID, false, undefined, {}, RORY_EMAIL); await waitForBatchedUpdates(); @@ -3777,7 +3743,6 @@ describe('actions/IOU', () => { policyRecentlyUsedCurrencies: [], quickAction: undefined, iouReportNextStep: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -3946,7 +3911,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -4056,7 +4020,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -4179,7 +4142,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -4231,7 +4193,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); return waitForBatchedUpdates() @@ -4312,7 +4273,7 @@ describe('actions/IOU', () => { .then(() => { mockFetch?.pause?.(); if (chatReport && iouReport) { - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined); } return waitForBatchedUpdates(); }) @@ -4479,7 +4440,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -4502,7 +4462,7 @@ describe('actions/IOU', () => { ) .then(() => { if (chatReport && expenseReport) { - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.VBBA, chatReport, expenseReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.VBBA, chatReport, expenseReport, undefined, undefined); } return waitForBatchedUpdates(); }) @@ -4622,7 +4582,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -4646,7 +4605,7 @@ describe('actions/IOU', () => { .then(() => { mockFetch?.fail?.(); if (chatReport && expenseReport) { - payMoneyRequest('ACH', chatReport, expenseReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest('ACH', chatReport, expenseReport, undefined, undefined); } return waitForBatchedUpdates(); }) @@ -4687,7 +4646,7 @@ describe('actions/IOU', () => { jest.advanceTimersByTime(10); // When paying the IOU report - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, iouReport, undefined, undefined); await waitForBatchedUpdates(); @@ -4789,7 +4748,7 @@ describe('actions/IOU', () => { }) .then(() => { // When partially paying an iou report from the chat report via the report preview - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, {reportID: topMostReportID}, iouReport, undefined, undefined, [CONST.BETAS.ALL], undefined, false); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, {reportID: topMostReportID}, iouReport, undefined, undefined, undefined, false); return waitForBatchedUpdates(); }) .then(() => { @@ -4871,18 +4830,7 @@ describe('actions/IOU', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${expenseReport.reportID}`, expenseReport); await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, chatReport); - const newExpenseReportID = payMoneyRequest( - CONST.IOU.PAYMENT_TYPE.ELSEWHERE, - chatReport, - expenseReport, - undefined, - undefined, - [CONST.BETAS.ALL], - undefined, - false, - undefined, - policy, - ); + const newExpenseReportID = payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined, undefined, false, undefined, policy); await waitForBatchedUpdates(); const newExpenseReport = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}${newExpenseReportID}`); expect(newExpenseReport?.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); @@ -4951,7 +4899,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -4970,7 +4917,7 @@ describe('actions/IOU', () => { .then(() => { // When the expense report is paid elsewhere (but really, any payment option would work) if (chatReport && expenseReport) { - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined); } return waitForBatchedUpdates(); }) @@ -5059,7 +5006,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); await waitForBatchedUpdates(); @@ -5306,7 +5252,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -5885,7 +5830,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -5960,7 +5904,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); await waitForBatchedUpdates(); @@ -6366,7 +6309,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -6494,7 +6436,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: initialCurrencies, - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -6565,7 +6506,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [], quickAction: undefined, }); } @@ -6762,7 +6702,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [], quickAction: undefined, }); } @@ -6932,7 +6871,6 @@ describe('actions/IOU', () => { currentUserEmailParam: RORY_EMAIL, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -7578,7 +7516,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -7632,7 +7569,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -8431,7 +8367,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -8527,7 +8462,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); } @@ -8545,7 +8479,7 @@ describe('actions/IOU', () => { // When the expense report is paid elsewhere (but really, any payment option would work) if (chatReport && expenseReport) { mockFetch?.pause?.(); - payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined, [CONST.BETAS.ALL]); + payMoneyRequest(CONST.IOU.PAYMENT_TYPE.ELSEWHERE, chatReport, expenseReport, undefined, undefined); } await waitForBatchedUpdates(); @@ -9256,7 +9190,7 @@ describe('actions/IOU', () => { await waitForBatchedUpdates(); - createNewReport(creatorPersonalDetails, true, false, mockPolicy, [CONST.BETAS.ALL], undefined, undefined); + createNewReport(creatorPersonalDetails, true, false, mockPolicy); // Create a tracked expense const selfDMReport: Report = { ...createRandomReport(1, CONST.REPORT.CHAT_TYPE.SELF_DM), @@ -9288,7 +9222,6 @@ describe('actions/IOU', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await getOnyxData({ key: ONYXKEYS.COLLECTION.TRANSACTION, @@ -9439,7 +9372,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); await waitForBatchedUpdates(); @@ -9539,7 +9471,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -9599,7 +9530,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); await waitForBatchedUpdates(); @@ -9699,7 +9629,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -9764,7 +9693,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); await waitForBatchedUpdates(); @@ -9873,7 +9801,6 @@ describe('actions/IOU', () => { currentUserPersonalDetails, transactionViolations: {}, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, iouReportNextStep: undefined, }); @@ -9940,7 +9867,6 @@ describe('actions/IOU', () => { transactionViolations: {}, policyRecentlyUsedCurrencies: [], quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -10071,7 +9997,6 @@ describe('actions/IOU', () => { transactionViolations: {}, policyRecentlyUsedCurrencies: [], quickAction: undefined, - allBetas: [CONST.BETAS.ALL], iouReportNextStep: undefined, }); @@ -10262,7 +10187,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'payee@example.com', hasViolations: false, policyRecentlyUsedCurrencies: initialCurrencies, - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -10351,7 +10275,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', hasViolations: false, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -10484,7 +10407,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', hasViolations: false, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -10571,7 +10493,6 @@ describe('actions/IOU', () => { currentUserEmailParam: 'existing@example.com', hasViolations: false, policyRecentlyUsedCurrencies: [], - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -10639,7 +10560,6 @@ describe('actions/IOU', () => { policy: {...createRandomPolicy(1)}, policyRecentlyUsedTags, }, - allBetas: [CONST.BETAS.ALL], quickAction: undefined, }); @@ -10827,7 +10747,7 @@ describe('actions/IOU', () => { if (!transaction?.transactionID || !iouReport?.reportID) { throw new Error('Required transaction or report data is missing'); } - const result = rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy, [CONST.BETAS.ALL]); + const result = rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy); // Then: Should return navigation route to chat report expect(result).toBe(ROUTES.REPORT_WITH_ID.getRoute(iouReport.reportID)); @@ -10843,7 +10763,7 @@ describe('actions/IOU', () => { if (!transaction?.transactionID || !iouReport?.reportID) { throw new Error('Required transaction or report data is missing'); } - rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy, [CONST.BETAS.ALL]); + rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy); await waitForBatchedUpdates(); // Then: Verify violation is added @@ -10899,7 +10819,7 @@ describe('actions/IOU', () => { if (!transaction?.transactionID || !iouReport?.reportID) { throw new Error('Required transaction or report data is missing'); } - rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy, [CONST.BETAS.ALL]); + rejectMoneyRequest(transaction.transactionID, iouReport.reportID, comment, policy); await waitForBatchedUpdates(); // Then: createdIOUReportActionID shouldn't be undefined @@ -11106,7 +11026,7 @@ describe('actions/IOU', () => { }); // Admin approves the report - approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be approved since admin took control and is the last approver @@ -11144,7 +11064,7 @@ describe('actions/IOU', () => { }); // Manager approves the report - approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be submitted to senior manager (normal flow) since take control was invalidated @@ -11178,7 +11098,7 @@ describe('actions/IOU', () => { }); // Admin approves the report - approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined); await waitForBatchedUpdates(); // Get the optimistic next step @@ -11288,7 +11208,7 @@ describe('actions/IOU', () => { }); // Manager approves the report (no take control actions) - approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be submitted to admin (next in approval chain) since manager is not the final approver @@ -11305,7 +11225,7 @@ describe('actions/IOU', () => { accountID: managerAccountID, }); - approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(expenseReport, policy, managerAccountID, managerEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be submitted to admin @@ -11320,7 +11240,7 @@ describe('actions/IOU', () => { accountID: adminAccountID, }); - approveMoneyRequest(updatedReport, policy, adminAccountID, adminEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(updatedReport, policy, adminAccountID, adminEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be fully approved @@ -11365,7 +11285,7 @@ describe('actions/IOU', () => { }); // Manager approves the report - approveMoneyRequest(singleApproverReport, singleApproverPolicy, managerAccountID, managerEmail, false, false, undefined, [CONST.BETAS.ALL]); + approveMoneyRequest(singleApproverReport, singleApproverPolicy, managerAccountID, managerEmail, false, false, undefined); await waitForBatchedUpdates(); // Should be fully approved since manager is the final approver in the chain @@ -11466,7 +11386,7 @@ describe('actions/IOU', () => { accountID: adminAccountID, }); - const newExpenseReportID = approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined, [CONST.BETAS.ALL], false); + const newExpenseReportID = approveMoneyRequest(expenseReport, policy, adminAccountID, adminEmail, false, false, undefined, false); await waitForBatchedUpdates(); const newExpenseReport = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT}${newExpenseReportID}`); diff --git a/tests/actions/IOUTest/DuplicateTest.ts b/tests/actions/IOUTest/DuplicateTest.ts index f3812caf41fc4..5f60632f0d6a2 100644 --- a/tests/actions/IOUTest/DuplicateTest.ts +++ b/tests/actions/IOUTest/DuplicateTest.ts @@ -704,7 +704,6 @@ describe('actions/Duplicate', () => { targetPolicy: mockPolicy, targetPolicyCategories: fakePolicyCategories, targetReport: policyExpenseChat, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); @@ -760,7 +759,6 @@ describe('actions/Duplicate', () => { targetPolicy: mockPolicy, targetPolicyCategories: fakePolicyCategories, targetReport: policyExpenseChat, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index b44284d34b125..690c2977ec05f 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -1850,7 +1850,7 @@ describe('actions/Report', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy); mockFetchData.pause(); - const {reportID} = Report.createNewReport({accountID}, true, false, policy, [CONST.BETAS.ALL], undefined, undefined); + const {reportID} = Report.createNewReport({accountID}, true, false, policy); const parentReport = ReportUtils.getPolicyExpenseChat(accountID, policyID); const reportPreviewAction = await new Promise>>((resolve) => { @@ -1923,7 +1923,7 @@ describe('actions/Report', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy); mockFetchData.pause(); - Report.createNewReport({accountID}, true, false, policy, [CONST.BETAS.ALL], undefined, undefined); + Report.createNewReport({accountID}, true, false, policy); const parentReport = ReportUtils.getPolicyExpenseChat(accountID, policyID); await new Promise((resolve) => { @@ -1961,7 +1961,7 @@ describe('actions/Report', () => { } // When create new report - Report.createNewReport({accountID}, true, false, policy, [CONST.BETAS.ALL], undefined, undefined); + Report.createNewReport({accountID}, true, false, policy); // Then the parent report's hasOutstandingChildRequest property should remain unchanged await new Promise((resolve) => { @@ -2005,7 +2005,7 @@ describe('actions/Report', () => { }; await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy); - const {reportID} = Report.createNewReport({accountID}, true, false, policy, [CONST.BETAS.ALL]); + const {reportID} = Report.createNewReport({accountID}, true, false, policy); const parentReport = ReportUtils.getPolicyExpenseChat(accountID, policyID); await waitForBatchedUpdates(); diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index 88f5908768505..932993811fcb1 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -204,7 +204,7 @@ describe('ReportUtils', () => { const reportParticipants = Array.from({length: 1000}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => temporary_getMoneyRequestOptions(report, policy, reportParticipants, [CONST.BETAS.ALL])); + await measureFunction(() => temporary_getMoneyRequestOptions(report, policy, reportParticipants)); }); test('[ReportUtils] getWorkspaceChat on 1k policies', async () => { diff --git a/tests/ui/LHNItemsPresence.tsx b/tests/ui/LHNItemsPresence.tsx index b7b1b911f8d1d..6fb7cfea6e414 100644 --- a/tests/ui/LHNItemsPresence.tsx +++ b/tests/ui/LHNItemsPresence.tsx @@ -545,14 +545,7 @@ describe('SidebarLinksData', () => { it('should not display the single transaction thread', async () => { // Given the SidebarLinks are rendered LHNTestUtils.getDefaultRenderedSidebarLinks(); - const expenseReport = buildOptimisticExpenseReport({ - chatReportID: chatReportR14932.reportID, - policyID: '123', - payeeAccountID: 100, - total: 122, - currency: 'USD', - allBetas: [CONST.BETAS.ALL], - }); + const expenseReport = buildOptimisticExpenseReport(chatReportR14932.reportID, '123', 100, 122, 'USD'); const expenseTransaction = buildOptimisticTransaction({ transactionParams: { amount: 100, diff --git a/tests/ui/PaginationTest.tsx b/tests/ui/PaginationTest.tsx index ad94d7a334f88..202e4531f421e 100644 --- a/tests/ui/PaginationTest.tsx +++ b/tests/ui/PaginationTest.tsx @@ -208,7 +208,7 @@ async function fastSignInWithTestUser() { email: USER_A_EMAIL, encryptedAuthToken: TEST_AUTH_TOKEN, }, - [ONYXKEYS.BETAS]: [CONST.BETAS.ALL], + [ONYXKEYS.BETAS]: ['all'], [ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: 'randomID', [ONYXKEYS.PERSONAL_DETAILS_LIST]: { [USER_A_ACCOUNT_ID]: TestHelper.buildPersonalDetails(USER_A_EMAIL, USER_A_ACCOUNT_ID, 'A'), diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 129b637493727..c9b27b702b0b5 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -157,7 +157,7 @@ async function fastSignInWithTestUser() { email: USER_A_EMAIL, encryptedAuthToken: TEST_AUTH_TOKEN, }, - [ONYXKEYS.BETAS]: [CONST.BETAS.ALL], + [ONYXKEYS.BETAS]: ['all'], [ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID]: 'randomID', [ONYXKEYS.PERSONAL_DETAILS_LIST]: { [USER_A_ACCOUNT_ID]: TestHelper.buildPersonalDetails(USER_A_EMAIL, USER_A_ACCOUNT_ID, 'A'), @@ -720,7 +720,6 @@ describe('Unread Indicators', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdates(); diff --git a/tests/unit/GoogleTagManagerTest.tsx b/tests/unit/GoogleTagManagerTest.tsx index 2c8dfc9f201d9..2d93af6bfb83c 100644 --- a/tests/unit/GoogleTagManagerTest.tsx +++ b/tests/unit/GoogleTagManagerTest.tsx @@ -197,7 +197,6 @@ describe('GoogleTagManagerTest', () => { introSelected: undefined, activePolicyID: undefined, quickAction: undefined, - allBetas: [CONST.BETAS.ALL], }); await waitForBatchedUpdatesWithAct(); diff --git a/tests/unit/IOUUtilsTest.ts b/tests/unit/IOUUtilsTest.ts index 10fbcf46c6bd0..ae9dd35869670 100644 --- a/tests/unit/IOUUtilsTest.ts +++ b/tests/unit/IOUUtilsTest.ts @@ -611,7 +611,7 @@ describe('Check valid amount for IOU/Expense request', () => { }); test('Expense amount should be negative', () => { - const expenseReport = ReportUtils.buildOptimisticExpenseReport({chatReportID: '212', policyID: '123', payeeAccountID: 100, total: 122, currency: 'USD', allBetas: [CONST.BETAS.ALL]}); + const expenseReport = ReportUtils.buildOptimisticExpenseReport('212', '123', 100, 122, 'USD'); const expenseTransaction = TransactionUtils.buildOptimisticTransaction({ transactionParams: { amount: 100, diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 4707837e4e9c8..1a7f19c0d0063 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -39,14 +39,7 @@ describe('libs/NextStepUtils', () => { icon: CONST.NEXT_STEP.ICONS.HOURGLASS, message: [], }; - const report = buildOptimisticExpenseReport({ - chatReportID: 'fake-chat-report-id-1', - policyID, - payeeAccountID: 1, - total: -500, - currency: CONST.CURRENCY.USD, - allBetas: [CONST.BETAS.ALL], - }) as Report; + const report = buildOptimisticExpenseReport('fake-chat-report-id-1', policyID, 1, -500, CONST.CURRENCY.USD) as Report; beforeAll(() => { const policyCollectionDataSet = toCollectionDataSet(ONYXKEYS.COLLECTION.POLICY, [policy], (item) => item.id); @@ -92,7 +85,6 @@ describe('libs/NextStepUtils', () => { 'fake-parent-report-action-id-4', policy, '2025-03-31 13:23:11', - [CONST.BETAS.ALL], ); optimisticNextStep.message = [ diff --git a/tests/unit/QuickActionUtilsTest.ts b/tests/unit/QuickActionUtilsTest.ts index f244a57fd963e..cb5bb3f317eae 100644 --- a/tests/unit/QuickActionUtilsTest.ts +++ b/tests/unit/QuickActionUtilsTest.ts @@ -41,7 +41,7 @@ describe('QuickActionUtils', () => { mockedPolicyUtils.shouldShowPolicy.mockReturnValue(false); // When the report contains Manager McTest - const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined, undefined, [CONST.BETAS.ALL]); + const result = isQuickActionAllowed(requestScanAction, reportWithManagerMcTest, undefined, undefined); // Then it should return false expect(result).toBe(false); @@ -93,24 +93,24 @@ describe('QuickActionUtils', () => { }; it('should restrict REQUEST action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, false); + const withRestrictionsResult = isQuickActionAllowed(requestManualAction, DMReport, undefined, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); }); it('should restrict SPLIT action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, DMReport, undefined, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); }); it('should restrict SEND_MONEY action on DMs', () => { - const withoutRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, false); + const withRestrictionsResult = isQuickActionAllowed(sendMoneyAction, DMReport, undefined, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -119,8 +119,8 @@ describe('QuickActionUtils', () => { it('should restrict SPLIT action on Group chats', () => { const groupChatReport: Report = LHNTestUtils.getFakeReport([1, 2, 3, 4]); - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, groupChatReport, undefined, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -132,8 +132,8 @@ describe('QuickActionUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, false); + const withRestrictionsResult = isQuickActionAllowed(splitManualAction, policyRoomReport, undefined, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -187,7 +187,7 @@ describe('QuickActionUtils', () => { } as unknown as Policy; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(true); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(true); }); it("should not allow per diem action when policy doesn't have per diem rates", () => { mockedPolicyUtils.getPerDiemCustomUnit.mockReturnValue(undefined); @@ -195,14 +195,14 @@ describe('QuickActionUtils', () => { id: '1', arePerDiemRatesEnabled: true, } as unknown as Policy; - expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(false); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false); }); it("should not allow per diem action when policy doesn't have per diem enabled", () => { const policy = { id: '1', arePerDiemRatesEnabled: false, } as unknown as Policy; - expect(isQuickActionAllowed(perDiemAction, report, policy, false, [CONST.BETAS.ALL], false)).toBe(false); + expect(isQuickActionAllowed(perDiemAction, report, policy, false, false)).toBe(false); }); }); }); diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index 1f9d351d363d7..327066c8d7f9d 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -72,7 +72,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }), ).toEqual(result); }); @@ -109,7 +108,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.ADD_EXPENSE)).toBe(true); }); @@ -142,7 +140,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(true); }); @@ -175,7 +172,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(true); }); @@ -222,7 +218,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(true); }); @@ -254,7 +249,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(false); }); @@ -303,7 +297,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(true); }); @@ -338,7 +331,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(false); }); @@ -378,7 +370,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(false); }); @@ -424,7 +415,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(false); }); @@ -464,7 +454,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(true); }); @@ -503,7 +492,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(false); }); @@ -544,7 +532,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(true); }); @@ -585,7 +572,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(false); }); @@ -623,7 +609,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(true); }); @@ -661,7 +646,6 @@ describe('getSecondaryAction', () => { violations: {[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${TRANSACTION_ID}`]: [violation]}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(false); }); @@ -696,7 +680,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE)).toBe(false); }); @@ -722,7 +705,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(true); }); @@ -751,7 +733,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(true); }); @@ -779,7 +760,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(true); }); @@ -807,7 +787,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); }); @@ -836,7 +815,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); }); @@ -865,7 +843,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); }); @@ -895,7 +872,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); }); @@ -925,7 +901,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true); }); @@ -977,7 +952,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true); }); @@ -1029,7 +1003,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true); }); @@ -1081,7 +1054,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true); }); @@ -1133,7 +1105,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true); }); @@ -1166,7 +1137,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions: [actionR14932], - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.HOLD)).toBe(true); }); @@ -1211,7 +1181,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, policies, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(false); }); @@ -1257,7 +1226,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, policies, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(true); }); @@ -1318,7 +1286,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy: oldPolicy, policies, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(true); }); @@ -1379,7 +1346,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, policies, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(true); }); @@ -1440,7 +1406,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, policies, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(true); }); @@ -1466,7 +1431,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1532,7 +1496,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1578,7 +1541,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1639,7 +1601,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(false); }); @@ -1684,7 +1645,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1735,7 +1695,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1777,7 +1736,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(false); }); @@ -1815,7 +1773,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(false); }); @@ -1869,7 +1826,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(false); }); @@ -1912,7 +1868,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DELETE)).toBe(true); }); @@ -1943,7 +1898,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result).toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD); }); @@ -1978,7 +1932,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result).not.toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD); }); @@ -2024,7 +1977,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(true); }); @@ -2055,7 +2007,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, originalTransaction: {} as Transaction, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(false); }); @@ -2116,7 +2067,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(false); }); @@ -2157,7 +2107,6 @@ describe('getSecondaryAction', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(false); }); @@ -2203,7 +2152,6 @@ describe('getSecondaryAction', () => { bankAccountList: {}, policy, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(false); }); @@ -2469,7 +2417,6 @@ describe('getSecondaryExportReportActions', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result).toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD); }); @@ -2603,7 +2550,6 @@ describe('getSecondaryTransactionThreadActions', () => { policy, policies, reportActions, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE)).toBe(false); }); @@ -2772,7 +2718,6 @@ describe('getSecondaryTransactionThreadActions', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.MERGE)).toBe(true); @@ -2827,7 +2772,6 @@ describe('getSecondaryTransactionThreadActions', () => { violations: {}, bankAccountList: {}, policy, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.MERGE)).toBe(true); @@ -2851,7 +2795,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(false); @@ -2873,7 +2816,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(false); @@ -2895,7 +2837,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(false); @@ -2916,7 +2857,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(false); @@ -2938,7 +2878,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(true); @@ -2960,7 +2899,6 @@ describe('getSecondaryTransactionThreadActions', () => { originalTransaction: {} as Transaction, violations: {}, bankAccountList: {}, - allBetas: [CONST.BETAS.ALL], }); expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.REPORT_LAYOUT)).toBe(true); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 223a90cb8a55a..d14f7b271b10d 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -65,7 +65,6 @@ import { getDefaultWorkspaceAvatar, getDisplayNameForParticipant, getDisplayNamesWithTooltips, - getExpenseReportStateAndStatus, getHarvestOriginalReportID, getHelpPaneReportType, getIconsForParticipants, @@ -108,7 +107,6 @@ import { requiresAttentionFromCurrentUser, requiresManualSubmission, shouldBlockSubmitDueToStrictPolicyRules, - shouldCreateNewMoneyRequestReport, shouldDisableRename, shouldDisableThread, shouldDisplayViolationsRBRInLHN, @@ -2796,7 +2794,7 @@ describe('ReportUtils', () => { describe('return empty iou options if', () => { it('participants array contains excluded expensify iou emails', () => { const allEmpty = CONST.EXPENSIFY_ACCOUNT_IDS.every((accountID) => { - const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(undefined, undefined, [currentUserAccountID, accountID]); return moneyRequestOptions.length === 0; }); expect(allEmpty).toBe(true); @@ -2807,7 +2805,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2817,7 +2815,7 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, isOwnPolicyExpenseChat: false, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2827,7 +2825,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.IOU, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2838,7 +2836,7 @@ describe('ReportUtils', () => { stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.APPROVED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2848,7 +2846,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL], true); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], true); expect(moneyRequestOptions.length).toBe(0); }); @@ -2858,7 +2856,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, chatType: CONST.REPORT.CHAT_TYPE.TRIP_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2868,7 +2866,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.EXPENSE, statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); @@ -2882,7 +2880,7 @@ describe('ReportUtils', () => { parentReportID: '100', type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -2892,7 +2890,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.EXPENSE, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20]); expect(moneyRequestOptions.length).toBe(0); }); it('the current user is an invited user of the iou report', () => { @@ -2902,7 +2900,7 @@ describe('ReportUtils', () => { ownerAccountID: 20, managerID: 21, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, 20, 21]); expect(moneyRequestOptions.length).toBe(0); }); }); @@ -2914,12 +2912,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); return moneyRequestOptions.length === 1 && moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT); }); expect(onlyHaveSplitOption).toBe(true); @@ -2930,7 +2923,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -2940,7 +2933,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -2951,7 +2944,7 @@ describe('ReportUtils', () => { type: CONST.REPORT.TYPE.CHAT, participantsAccountIDs: [currentUserAccountID, ...participantsAccountIDs], }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs.map(Number)]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); }); @@ -2966,12 +2959,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -2984,12 +2972,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3009,7 +2992,7 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, }; mockedPolicyUtils.isPaidGroupPolicy.mockReturnValue(true); - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3040,12 +3023,7 @@ describe('ReportUtils', () => { outputCurrency: '', isPolicyExpenseChatEnabled: false, } as const; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - paidPolicy, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3061,12 +3039,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3079,12 +3052,7 @@ describe('ReportUtils', () => { statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(1); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); }); @@ -3127,12 +3095,7 @@ describe('ReportUtils', () => { managerID: currentUserAccountID, ownerAccountID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - paidPolicy, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3147,12 +3110,7 @@ describe('ReportUtils', () => { ...LHNTestUtils.getFakeReport(), type: CONST.REPORT.TYPE.CHAT, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(3); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3188,12 +3146,7 @@ describe('ReportUtils', () => { ownerAccountID: currentUserAccountID, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - paidPolicy, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, paidPolicy, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3207,7 +3160,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, managerID: currentUserAccountID, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs], [CONST.BETAS.ALL]); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, ...participantsAccountIDs]); expect(moneyRequestOptions.length).toBe(2); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(moneyRequestOptions.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3227,12 +3180,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); // Should not include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3249,12 +3197,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - report, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(report, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); // Should include SUBMIT (Create Expense) expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); @@ -3275,12 +3218,7 @@ describe('ReportUtils', () => { isOwnPolicyExpenseChat: true, }; - const moneyRequestOptions = temporary_getMoneyRequestOptions( - expenseReport, - undefined, - [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID], - [CONST.BETAS.ALL], - ); + const moneyRequestOptions = temporary_getMoneyRequestOptions(expenseReport, undefined, [currentUserAccountID, participantsAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID]); // Should not include SUBMIT expect(moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3300,8 +3238,8 @@ describe('ReportUtils', () => { }; const selfDMParticipants = [currentUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(selfDMReport, undefined, selfDMParticipants, false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.TRACK)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.TRACK)).toBe(true); @@ -3320,8 +3258,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SUBMIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SUBMIT)).toBe(false); @@ -3339,8 +3277,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); if (withoutRestrictionsResult.includes(CONST.IOU.TYPE.PAY)) { expect(withRestrictionsResult.includes(CONST.IOU.TYPE.PAY)).toBe(false); @@ -3359,8 +3297,8 @@ describe('ReportUtils', () => { }; const dmParticipants = [currentUserAccountID, otherUserAccountID]; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(dmReport, undefined, dmParticipants, false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3376,8 +3314,8 @@ describe('ReportUtils', () => { chatType: undefined, }; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(groupChatReport, undefined, groupParticipants, false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3393,8 +3331,8 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, [CONST.BETAS.ALL], false, false); - const withRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, [CONST.BETAS.ALL], false, true); + const withoutRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, false, false); + const withRestrictionsResult = temporary_getMoneyRequestOptions(policyRoomReport, undefined, policyRoomParticipants, false, true); expect(withoutRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(true); expect(withRestrictionsResult.includes(CONST.IOU.TYPE.SPLIT)).toBe(false); @@ -3417,8 +3355,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, false); + const withRestrictionsResult = canCreateRequest(selfDMReport, undefined, CONST.IOU.TYPE.TRACK, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(true); @@ -3437,8 +3375,8 @@ describe('ReportUtils', () => { }, }; - const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, false); + const withRestrictionsResult = canCreateRequest(dmReport, undefined, CONST.IOU.TYPE.SPLIT, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3449,8 +3387,8 @@ describe('ReportUtils', () => { it('should restrict SPLIT requests for group chats', () => { const groupChat = LHNTestUtils.getFakeReport([currentUserAccountID, ...participantsAccountIDs.slice(0, 3)]); - const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, false); + const withRestrictionsResult = canCreateRequest(groupChat, undefined, CONST.IOU.TYPE.SPLIT, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3464,8 +3402,8 @@ describe('ReportUtils', () => { chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, }; - const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], false); - const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, [CONST.BETAS.ALL], true); + const withoutRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, false); + const withRestrictionsResult = canCreateRequest(policyRoom, undefined, CONST.IOU.TYPE.SPLIT, false, true); expect(withoutRestrictionsResult).toBe(true); expect(withRestrictionsResult).toBe(false); @@ -3839,15 +3777,7 @@ describe('ReportUtils', () => { it('should return canUnholdRequest as true for a held duplicate transaction', async () => { const chatReport: Report = {reportID: '1'}; const reportPreviewReportActionID = '8'; - const expenseReport = buildOptimisticExpenseReport({ - chatReportID: chatReport.reportID, - policyID: '123', - payeeAccountID: currentUserAccountID, - total: 122, - currency: 'USD', - allBetas: [CONST.BETAS.ALL], - optimisticIOUReportID: reportPreviewReportActionID, - }); + const expenseReport = buildOptimisticExpenseReport(chatReport.reportID, '123', currentUserAccountID, 122, 'USD', undefined, reportPreviewReportActionID); const expenseTransaction = buildOptimisticTransaction({ transactionParams: { amount: 100, @@ -4334,7 +4264,7 @@ describe('ReportUtils', () => { }); it('should return true when the report has outstanding violations', async () => { - const expenseReport = buildOptimisticExpenseReport({chatReportID: '212', policyID: '123', payeeAccountID: 100, total: 122, currency: 'USD', allBetas: [CONST.BETAS.ALL]}); + const expenseReport = buildOptimisticExpenseReport('212', '123', 100, 122, 'USD'); const expenseTransaction = buildOptimisticTransaction({ transactionParams: { amount: 100, @@ -4649,7 +4579,7 @@ describe('ReportUtils', () => { }); it('should return false when the report is the single transaction thread', async () => { - const expenseReport = buildOptimisticExpenseReport({chatReportID: '212', policyID: '123', payeeAccountID: 100, total: 122, currency: 'USD', allBetas: [CONST.BETAS.ALL]}); + const expenseReport = buildOptimisticExpenseReport('212', '123', 100, 122, 'USD'); const expenseTransaction = buildOptimisticTransaction({ transactionParams: { amount: 100, @@ -9253,186 +9183,11 @@ describe('ReportUtils', () => { const total = 100; const currency = CONST.CURRENCY.USD; - const expenseReport = buildOptimisticExpenseReport({chatReportID, policyID: undefined, payeeAccountID: 1, total, currency, allBetas: [CONST.BETAS.ALL]}); + const expenseReport = buildOptimisticExpenseReport(chatReportID, undefined, 1, total, currency); expect(expenseReport.reportName).toBe(`${fakePolicy.name} owes ${convertToDisplayString(-total, currency)}`); }); }); - describe('getExpenseReportStateAndStatus with betas', () => { - it('should return OPEN state/status when ASAP_SUBMIT beta is enabled', () => { - const testPolicy: Policy = { - ...createRandomPolicy(1), - autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - }; - const betas: Beta[] = [CONST.BETAS.ASAP_SUBMIT]; - - const result = getExpenseReportStateAndStatus(testPolicy, betas); - - expect(result.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); - expect(result.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); - }); - - it('should return SUBMITTED state/status when ASAP_SUBMIT beta is disabled and instant submit is enabled', () => { - const testPolicy: Policy = { - ...createRandomPolicy(1), - autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES, - }; - const betas: Beta[] = []; - - const result = getExpenseReportStateAndStatus(testPolicy, betas); - - expect(result.stateNum).toBe(CONST.REPORT.STATE_NUM.SUBMITTED); - expect(result.statusNum).toBe(CONST.REPORT.STATUS_NUM.SUBMITTED); - }); - - it('should return CLOSED state/status when instant submit + submit and close + payments disabled + ASAP_SUBMIT beta is off', () => { - const testPolicy: Policy = { - ...createRandomPolicy(1), - autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO, - approvalMode: CONST.POLICY.APPROVAL_MODE.OPTIONAL, - }; - const betas: Beta[] = []; - - const result = getExpenseReportStateAndStatus(testPolicy, betas, false); - - expect(result.stateNum).toBe(CONST.REPORT.STATE_NUM.APPROVED); - expect(result.statusNum).toBe(CONST.REPORT.STATUS_NUM.CLOSED); - }); - - it('should return OPEN state/status when no instant submit and ASAP_SUBMIT beta is disabled', () => { - const testPolicy: Policy = { - ...createRandomPolicy(1), - autoReporting: false, - }; - const betas: Beta[] = []; - - const result = getExpenseReportStateAndStatus(testPolicy, betas); - - expect(result.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); - expect(result.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); - }); - - it('should return OPEN state/status with undefined betas when ASAP_SUBMIT would be needed', () => { - const testPolicy: Policy = { - ...createRandomPolicy(1), - autoReporting: false, - }; - - const result = getExpenseReportStateAndStatus(testPolicy, undefined); - - expect(result.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); - expect(result.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); - }); - }); - - describe('shouldCreateNewMoneyRequestReport with betas', () => { - const testChatReport: Report = { - ...createRandomReport(100, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT), - policyID: '1', - ownerAccountID: currentUserAccountID, - }; - - it('should return true when no existing IOU report', () => { - const betas: Beta[] = [CONST.BETAS.ALL]; - const result = shouldCreateNewMoneyRequestReport(undefined, testChatReport, false, betas); - expect(result).toBe(true); - }); - - it('should return true for scan request when ASAP_SUBMIT beta is enabled (creates new report per scan)', () => { - const existingIOUReport: Report = { - ...createRandomReport(200, undefined), - type: CONST.REPORT.TYPE.EXPENSE, - ownerAccountID: currentUserAccountID, - stateNum: CONST.REPORT.STATE_NUM.OPEN, - statusNum: CONST.REPORT.STATUS_NUM.OPEN, - }; - const betas: Beta[] = [CONST.BETAS.ASAP_SUBMIT]; - - // With ASAP_SUBMIT beta enabled, scan requests should create new reports - const result = shouldCreateNewMoneyRequestReport(existingIOUReport, testChatReport, true, betas); - expect(result).toBe(true); - }); - - it('should return true when existing report has createChat error', () => { - const existingIOUReport: Report = { - ...createRandomReport(200, undefined), - type: CONST.REPORT.TYPE.EXPENSE, - errorFields: { - createChat: {error: 'Some error'}, - }, - }; - const betas: Beta[] = []; - - const result = shouldCreateNewMoneyRequestReport(existingIOUReport, testChatReport, false, betas); - expect(result).toBe(true); - }); - - it('should check ASAP_SUBMIT beta in conjunction with isScanRequest to determine new report creation', () => { - const existingIOUReport: Report = { - ...createRandomReport(200, undefined), - type: CONST.REPORT.TYPE.EXPENSE, - ownerAccountID: currentUserAccountID, - stateNum: CONST.REPORT.STATE_NUM.OPEN, - statusNum: CONST.REPORT.STATUS_NUM.OPEN, - }; - - // When ASAP_SUBMIT beta is enabled AND it's a scan request, new report should be created - const betasWithASAP: Beta[] = [CONST.BETAS.ASAP_SUBMIT]; - const resultWithBetaAndScan = shouldCreateNewMoneyRequestReport(existingIOUReport, testChatReport, true, betasWithASAP); - expect(resultWithBetaAndScan).toBe(true); - - // When ASAP_SUBMIT beta is disabled, the scan request flag alone doesn't force new report - const betasWithoutASAP: Beta[] = []; - const resultWithoutBeta = shouldCreateNewMoneyRequestReport(existingIOUReport, testChatReport, true, betasWithoutASAP); - // The result depends on canAddTransaction - we're just verifying the beta is being checked - expect(typeof resultWithoutBeta).toBe('boolean'); - }); - }); - - describe('buildOptimisticExpenseReport with betas', () => { - beforeEach(Onyx.clear); - - it('should create expense report with OPEN status when ASAP_SUBMIT beta is enabled', async () => { - const chatReportID = '1'; - const policyID = '2'; - const testPolicy: Policy = { - ...createRandomPolicy(Number(policyID)), - autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, testPolicy); - - const betas: Beta[] = [CONST.BETAS.ASAP_SUBMIT]; - const expenseReport = buildOptimisticExpenseReport({chatReportID, policyID, payeeAccountID: 1, total: 100, currency: CONST.CURRENCY.USD, allBetas: betas}); - - expect(expenseReport.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); - expect(expenseReport.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); - }); - - it('should create expense report with SUBMITTED status when ASAP_SUBMIT beta is disabled and instant submit enabled', async () => { - const chatReportID = '1'; - const policyID = '2'; - const testPolicy: Policy = { - ...createRandomPolicy(Number(policyID)), - autoReporting: true, - autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES, - }; - await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, testPolicy); - - const betas: Beta[] = []; - const expenseReport = buildOptimisticExpenseReport({chatReportID, policyID, payeeAccountID: 1, total: 100, currency: CONST.CURRENCY.USD, allBetas: betas}); - - expect(expenseReport.stateNum).toBe(CONST.REPORT.STATE_NUM.SUBMITTED); - expect(expenseReport.statusNum).toBe(CONST.REPORT.STATUS_NUM.SUBMITTED); - }); - }); - describe('hasEmptyReportsForPolicy', () => { const policyID = 'workspace-001'; const otherPolicyID = 'workspace-002';