From fdf3949098d322fd82536656c4cebad0ead6b36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Tue, 1 Oct 2024 11:25:15 +0100 Subject: [PATCH] Use allBetas from ReportUtils --- src/libs/ReportUtils.ts | 4 ++-- .../workspace/AccessOrNotFoundWrapper.tsx | 21 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7c0ee0ecaa0d..f7160e1cdf97 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6932,7 +6932,7 @@ function getReportOfflinePendingActionAndErrors(report: OnyxEntry): Repo /** * Check if the report can create the expense with type is iouType */ -function canCreateRequest(report: OnyxEntry, policy: OnyxEntry, betas: OnyxEntry, iouType: ValueOf): boolean { +function canCreateRequest(report: OnyxEntry, policy: OnyxEntry, iouType: ValueOf): boolean { const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); if (!canUserPerformWriteAction(report)) { @@ -6940,7 +6940,7 @@ function canCreateRequest(report: OnyxEntry, policy: OnyxEntry, } const requestOptions = getMoneyRequestOptions(report, policy, participantAccountIDs); - if (Permissions.canUseCombinedTrackSubmit(betas ?? [])) { + if (Permissions.canUseCombinedTrackSubmit(allBetas ?? [])) { requestOptions.push(CONST.IOU.TYPE.CREATE); } diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index b7b6f9a8030a..1a6f59830506 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -30,24 +30,16 @@ const ACCESS_VARIANTS = { login: string, report: OnyxEntry, allPolicies: NonNullable> | null, - betas: OnyxEntry, iouType?: IOUType, ) => !!iouType && IOUUtils.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) || ReportUtils.canCreateRequest(report, policy, betas, iouType)) && + (isEmptyObject(report?.reportID) || ReportUtils.canCreateRequest(report, policy, iouType)) && (iouType !== CONST.IOU.TYPE.INVOICE || PolicyUtils.canSendInvoice(allPolicies, login)), } as const satisfies Record< string, - ( - policy: OnyxTypes.Policy, - login: string, - report: OnyxTypes.Report, - allPolicies: NonNullable> | null, - betas: OnyxEntry, - iouType?: IOUType, - ) => boolean + (policy: OnyxTypes.Policy, login: string, report: OnyxTypes.Report, allPolicies: NonNullable> | null, iouType?: IOUType) => boolean >; type AccessVariant = keyof typeof ACCESS_VARIANTS; @@ -60,8 +52,6 @@ type AccessOrNotFoundWrapperOnyxProps = { /** Indicated whether the report data is loading */ isLoadingReportData: OnyxEntry; - - betas: OnyxEntry; }; type AccessOrNotFoundWrapperProps = AccessOrNotFoundWrapperOnyxProps & { @@ -113,7 +103,7 @@ function PageNotFoundFallback({policyID, shouldShowFullScreenFallback, fullPageN } function AccessOrNotFoundWrapper({accessVariants = [], fullPageNotFoundViewProps, shouldBeBlocked, ...props}: AccessOrNotFoundWrapperProps) { - const {policy, policyID, report, iouType, allPolicies, featureName, isLoadingReportData, betas} = props; + const {policy, policyID, report, iouType, allPolicies, featureName, isLoadingReportData} = props; const {login = ''} = useCurrentUserPersonalDetails(); const isPolicyIDInRoute = !!policyID?.length; const isMoneyRequest = !!iouType && IOUUtils.isValidMoneyRequestType(iouType); @@ -139,7 +129,7 @@ function AccessOrNotFoundWrapper({accessVariants = [], fullPageNotFoundViewProps const isPageAccessible = accessVariants.reduce((acc, variant) => { const accessFunction = ACCESS_VARIANTS[variant]; - return acc && accessFunction(policy, login, report, allPolicies ?? null, betas, iouType); + return acc && accessFunction(policy, login, report, allPolicies ?? null, iouType); }, true); const isPolicyNotAccessible = isEmptyObject(policy) || (Object.keys(policy).length === 1 && !isEmptyObject(policy.errors)) || !policy?.id; @@ -185,7 +175,4 @@ export default withOnyx