From cd28b2741c1ef7a9db593856c5d407b32078cae5 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 10 Mar 2026 22:52:55 +0800 Subject: [PATCH] pass userBillingGraceEndPeriods from useOnyx --- .../AttachmentPickerWithMenuItems.tsx | 5 +++-- .../useAttachmentUploadValidation.ts | 5 +++-- .../inbox/sidebar/FloatingActionButtonAndPopover.tsx | 11 ++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 1d1c9f603d0d0..3b87c3a21ecb9 100644 --- a/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/inbox/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -170,20 +170,21 @@ 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; const selectOption = useCallback( (onSelected: () => void, shouldRestrictAction: boolean) => { - if (shouldRestrictAction && policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && shouldRestrictUserBillableActions(policy.id)) { + if (shouldRestrictAction && policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } onSelected(); }, - [policy], + [policy, userBillingGraceEndPeriods], ); const {openCreateReportConfirmation, CreateReportConfirmationModal} = useCreateEmptyReportConfirmation({ diff --git a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts index e51b4e873dc21..9e1d7836d24a7 100644 --- a/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts +++ b/src/pages/inbox/report/ReportActionCompose/useAttachmentUploadValidation.ts @@ -56,6 +56,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); @@ -181,7 +182,7 @@ function useAttachmentUploadValidation({ const onReceiptDropped = useCallback( (e: DragEvent) => { - if (policy && shouldRestrictUserBillableActions(policy.id)) { + if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -202,7 +203,7 @@ function useAttachmentUploadValidation({ attachmentUploadType.current = 'receipt'; validateFiles(files, items, {isValidatingReceipts: true}); }, - [policy, shouldAddOrReplaceReceipt, transactionID, validateFiles], + [policy, userBillingGraceEndPeriods, shouldAddOrReplaceReceipt, transactionID, validateFiles], ); return { diff --git a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx index e91245da4ed14..f3db689faffa0 100644 --- a/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx @@ -194,6 +194,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 isUserPaidPolicyMember = useIsPaidPolicyAdmin(); const reportID = useMemo(() => generateReportID(), []); @@ -319,7 +320,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const selectOption = useCallback( (onSelected: () => void, shouldRestrictAction: boolean) => { - if (shouldRestrictAction && quickActionReport?.policyID && shouldRestrictUserBillableActions(quickActionReport.policyID)) { + if (shouldRestrictAction && quickActionReport?.policyID && shouldRestrictUserBillableActions(quickActionReport.policyID, userBillingGraceEndPeriods)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(quickActionReport.policyID)); return; } @@ -359,7 +360,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const startQuickScan = useCallback(() => { interceptAnonymousUser(() => { - if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID)) { + if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; } @@ -513,7 +514,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref if (!isEmptyObject(policyChatForActivePolicy)) { const onSelected = () => { interceptAnonymousUser(() => { - if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID)) { + if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID)); return; } @@ -617,13 +618,13 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref const workspaceIDForReportCreation = defaultChatEnabledPolicyID; - if (!workspaceIDForReportCreation || (shouldRestrictUserBillableActions(workspaceIDForReportCreation) && groupPoliciesWithChatEnabled.length > 1)) { + if (!workspaceIDForReportCreation || (shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods) && 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 Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute()); return; } - if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation)) { + if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods)) { // Check if empty report confirmation should be shown if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) { openFabCreateReportConfirmation();