diff --git a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 5e4d96e5c1c65..9042524681810 100644 --- a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -173,6 +173,7 @@ function AttachmentPickerWithMenuItems({ const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector}); const [hasDismissedEmptyReportsConfirmation] = useOnyx(ONYXKEYS.NVP_EMPTY_REPORTS_CONFIRMATION_DISMISSED); + const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, accountID ?? CONST.DEFAULT_NUMBER_ID, ''); const hasEmptyReport = useHasEmptyReportsForPolicy(report?.policyID); const shouldShowEmptyReportConfirmation = hasEmptyReport && hasDismissedEmptyReportsConfirmation !== true; @@ -183,7 +184,7 @@ function AttachmentPickerWithMenuItems({ shouldRestrictAction && policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && - shouldRestrictUserBillableActions(policy.id, undefined, undefined, ownerBillingGraceEndPeriod) + shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; @@ -191,7 +192,7 @@ function AttachmentPickerWithMenuItems({ onSelected(); }, - [policy, ownerBillingGraceEndPeriod], + [policy, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod], ); const {openCreateReportConfirmation, CreateReportConfirmationModal} = useCreateEmptyReportConfirmation({ diff --git a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts index fc8fe3ad4a652..b46023e583157 100644 --- a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts +++ b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts @@ -57,6 +57,7 @@ function useAttachmentUploadValidation({ const personalPolicy = usePersonalPolicy(); const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT); + const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const hasOnlyPersonalPolicies = useMemo(() => hasOnlyPersonalPoliciesUtil(allPolicies), [allPolicies]); const reportAttachmentsContext = useContext(AttachmentModalContext); @@ -182,7 +183,7 @@ function useAttachmentUploadValidation({ const onReceiptDropped = useCallback( (e: DragEvent) => { - if (policy && shouldRestrictUserBillableActions(policy.id, undefined, undefined, ownerBillingGraceEndPeriod)) { + if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -203,7 +204,7 @@ function useAttachmentUploadValidation({ attachmentUploadType.current = 'receipt'; validateFiles(files, items, {isValidatingReceipts: true}); }, - [policy, ownerBillingGraceEndPeriod, shouldAddOrReplaceReceipt, transactionID, validateFiles], + [policy, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod, shouldAddOrReplaceReceipt, transactionID, validateFiles], ); return { diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index f9106e46c45d2..b2769513802be 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -195,6 +195,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref selector: hasSeenTourSelector, }); const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector}); + const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END); const isUserPaidPolicyMember = useIsPaidPolicyAdmin(); @@ -321,13 +322,17 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const selectOption = useCallback( (onSelected: () => void, shouldRestrictAction: boolean) => { - if (shouldRestrictAction && quickActionReport?.policyID && shouldRestrictUserBillableActions(quickActionReport.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) { + if ( + shouldRestrictAction && + quickActionReport?.policyID && + shouldRestrictUserBillableActions(quickActionReport.policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) + ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(quickActionReport.policyID)); return; } onSelected(); }, - [quickActionReport?.policyID, ownerBillingGraceEndPeriod], + [quickActionReport?.policyID, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod], ); const showRedirectToExpensifyClassicModal = useCallback(async () => { @@ -361,7 +366,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const startQuickScan = useCallback(() => { interceptAnonymousUser(() => { - if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) { + if ( + policyChatForActivePolicy?.policyID && + shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) + ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; } @@ -370,7 +378,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref Tab.setSelectedTab(CONST.TAB.IOU_REQUEST_TYPE, CONST.IOU.REQUEST_TYPE.SCAN); startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, draftTransactionIDs, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, true); }); - }, [policyChatForActivePolicy?.policyID, policyChatForActivePolicy?.reportID, reportID, draftTransactionIDs, ownerBillingGraceEndPeriod]); + }, [policyChatForActivePolicy?.policyID, policyChatForActivePolicy?.reportID, reportID, draftTransactionIDs, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod]); /** * Check if LHN status changed from active to inactive. @@ -516,7 +524,10 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref if (!isEmptyObject(policyChatForActivePolicy)) { const onSelected = () => { interceptAnonymousUser(() => { - if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) { + if ( + policyChatForActivePolicy?.policyID && + shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) + ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; } @@ -567,6 +578,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref reportID, draftTransactionIDs, allBetas, + userBillingGraceEndPeriods, ownerBillingGraceEndPeriod, ]); @@ -623,7 +635,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref if ( !workspaceIDForReportCreation || - (shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod) && + (shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) && groupPoliciesWithChatEnabled.length > 1) ) { // If we couldn't guess the workspace to create the report, or a guessed workspace is past it's grace period and we have other workspaces to choose from @@ -631,7 +643,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref return; } - if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod)) { + if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) { // Check if empty report confirmation should be shown if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) { openFabCreateReportConfirmation();