Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -183,15 +184,15 @@ 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;
}

onSelected();
},
[policy, ownerBillingGraceEndPeriod],
[policy, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod],
);

const {openCreateReportConfirmation, CreateReportConfirmationModal} = useCreateEmptyReportConfirmation({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down
26 changes: 19 additions & 7 deletions src/pages/inbox/sidebar/FloatingActionButtonAndPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -567,6 +578,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref
reportID,
draftTransactionIDs,
allBetas,
userBillingGraceEndPeriods,
ownerBillingGraceEndPeriod,
]);

Expand Down Expand Up @@ -623,15 +635,15 @@ 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
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute());
return;
}

if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
// Check if empty report confirmation should be shown
if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) {
openFabCreateReportConfirmation();
Expand Down
Loading