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
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ function MoneyReportHeader({
icons: expensifyIcons,
iouReportID: moneyRequestReport?.reportID,
policy,
userBillingGraceEndPeriodCollection: userBillingGraceEndPeriods,
userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function MoneyRequestReportTransactionList({
const currentUserDetails = useCurrentUserPersonalDetails();
const isReportArchived = useReportIsArchived(report?.reportID);
const shouldShowAddExpenseButton = canAddTransaction(report, isReportArchived) && isCurrentUserSubmitter(report);
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
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 [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE);
const [reportLayoutGroupBy] = useOnyx(ONYXKEYS.NVP_REPORT_LAYOUT_GROUP_BY);
Expand All @@ -207,13 +207,13 @@ function MoneyRequestReportTransactionList({
icons: expensifyIcons,
iouReportID: report?.reportID,
policy,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
lastDistanceExpenseType,
}),
[translate, expensifyIcons, report?.reportID, policy, userBillingGraceEndPeriodCollection, amountOwed, lastDistanceExpenseType, ownerBillingGraceEndPeriod, draftTransactionIDs],
[translate, expensifyIcons, report?.reportID, policy, userBillingGraceEndPeriods, amountOwed, lastDistanceExpenseType, ownerBillingGraceEndPeriod, draftTransactionIDs],
);

const hasPendingAction = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type * as OnyxTypes from '@src/types/onyx';
const minModalHeight = 380;

function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy; onLayout?: (event: LayoutChangeEvent) => void}) {
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
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 [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`);
const {translate} = useLocalize();
Expand All @@ -43,7 +43,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
if (!reportId) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -58,7 +58,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
if (!reportId) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -70,7 +70,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
text: translate('iou.addUnreportedExpense'),
icon: icons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ function MoneyRequestReportPreviewContent({
icons: expensifyIcons,
iouReportID: iouReport?.reportID,
policy,
userBillingGraceEndPeriodCollection: userBillingGraceEndPeriods,
userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function SearchFiltersBarCreateButton() {
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const shouldNavigateToUpgradePath = !policyForMovingExpensesID && !shouldSelectPolicy;
const {showConfirmModal} = useConfirmModal();
Expand Down Expand Up @@ -184,14 +185,15 @@ function SearchFiltersBarCreateButton() {
// No default or restricted with multiple workspaces → workspace selector
if (
!workspaceIDForReportCreation ||
(shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod) && groupPoliciesWithChatEnabled.length > 1)
(shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod) &&
groupPoliciesWithChatEnabled.length > 1)
) {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute());
return;
}

// Default workspace is not restricted → create report directly
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
// Check if empty report confirmation should be shown
if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) {
openCreateReportConfirmation();
Expand All @@ -215,6 +217,8 @@ function SearchFiltersBarCreateButton() {
groupPoliciesWithChatEnabled.length,
defaultChatEnabledPolicyID,
shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy,
ownerBillingGraceEndPeriod,
userBillingGraceEndPeriods,
openCreateReportConfirmation,
handleCreateWorkspaceReport,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
const {translate} = useLocalize();
const {isLargeScreenWidth} = useResponsiveLayout();
const {currentSearchHash, currentSearchKey, currentSearchResults} = useSearchStateContext();
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [isActionLoading] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportItem.reportID}`, {selector: isActionLoadingSelector});
const expensifyIcons = useMemoizedLazyExpensifyIcons(['DotIndicator']);
const currentUserDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -129,6 +130,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
snapshotReport,
snapshotPolicy,
lastPaymentMethod,
userBillingGraceEndPeriods,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include billing grace periods in action callback dependencies

handleOnButtonPress now captures userBillingGraceEndPeriods but the useCallback dependency array was not updated, so when this Onyx collection arrives after initial render the callback can keep using a stale undefined value. In that state, handleActionButtonPress() may evaluate restrictions against outdated fallback data, allowing action-button flows on expense report rows to bypass the intended restricted-action redirect until another dependency happens to recreate the callback.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bernhardoj Please address this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why is this not caught by ESLisnt 🤔

Fixed

currentSearchKey,
onDEWModalOpen,
isDEWBetaEnabled,
Expand All @@ -143,6 +145,7 @@ function ExpenseReportListItem<TItem extends ListItem>({
snapshotReport,
snapshotPolicy,
lastPaymentMethod,
userBillingGraceEndPeriods,
personalPolicyID,
currentSearchKey,
onDEWModalOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ function ReportListItemHeader<TItem extends ListItem>({
const theme = useTheme();
const {currentSearchHash, currentSearchKey, currentSearchResults: snapshot} = useSearchStateContext();
const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const thereIsFromAndTo = !!reportItem?.from && !!reportItem?.to;
const showUserInfo = (reportItem.type === CONST.REPORT.TYPE.IOU && thereIsFromAndTo) || (reportItem.type === CONST.REPORT.TYPE.EXPENSE && !!reportItem?.from);
const snapshotReport = useMemo(() => {
Expand All @@ -245,6 +246,7 @@ function ReportListItemHeader<TItem extends ListItem>({
snapshotReport,
snapshotPolicy,
lastPaymentMethod,
userBillingGraceEndPeriods,
currentSearchKey,
onDEWModalOpen,
isDEWBetaEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function TransactionListItem<TItem extends ListItem>({
const {currentSearchHash, currentSearchKey, currentSearchResults} = useSearchStateContext();
const snapshotReport = (currentSearchResults?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID}`] ?? {}) as Report;

const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [isActionLoading] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${transactionItem.reportID}`, {selector: isActionLoadingSelector});

// Use active policy (user's current workspace) as fallback for self DM tracking expenses
Expand Down Expand Up @@ -158,6 +159,7 @@ function TransactionListItem<TItem extends ListItem>({
snapshotReport,
snapshotPolicy,
lastPaymentMethod,
userBillingGraceEndPeriods,
currentSearchKey,
onDEWModalOpen,
isDEWBetaEnabled,
Expand Down
14 changes: 7 additions & 7 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION);
const [allTransactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const personalPolicy = usePersonalPolicy();
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);

// Cache the last search results that had data, so the merge option remains available
// while results are temporarily unset (e.g. during sorting/loading).
Expand Down Expand Up @@ -379,7 +379,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {

const selectedItems = selectedReports.length ? selectedReports : Object.values(selectedTransactions);

const restrictedPolicyID = getRestrictedPolicyID(selectedItems, userBillingGraceEndPeriodCollection);
const restrictedPolicyID = getRestrictedPolicyID(selectedItems, userBillingGraceEndPeriods);
if (restrictedPolicyID) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictedPolicyID));
return;
Expand Down Expand Up @@ -428,7 +428,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
translate,
hash,
clearSelectedTransactions,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
]);

const {expenseCount, uniqueReportCount} = useMemo(() => {
Expand Down Expand Up @@ -557,7 +557,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
const selectedOptions = selectedReports.length ? selectedReports : Object.values(selectedTransactions);
const expenseReportBankAccountID = additionalData?.bankAccountID;

const restrictedPolicyID = getRestrictedPolicyID(selectedOptions, userBillingGraceEndPeriodCollection);
const restrictedPolicyID = getRestrictedPolicyID(selectedOptions, userBillingGraceEndPeriods);
if (restrictedPolicyID) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictedPolicyID));
return;
Expand Down Expand Up @@ -678,7 +678,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
personalPolicyID,
allTransactions,
allReports,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
],
);

Expand Down Expand Up @@ -962,7 +962,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {

const itemList = !selectedReports.length ? Object.values(selectedTransactions).map((transaction) => transaction) : (selectedReports?.filter((report) => !!report) ?? []);

const restrictedPolicyID = getRestrictedPolicyID(itemList, userBillingGraceEndPeriodCollection);
const restrictedPolicyID = getRestrictedPolicyID(itemList, userBillingGraceEndPeriods);
if (restrictedPolicyID) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(restrictedPolicyID));
return;
Expand Down Expand Up @@ -1222,7 +1222,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
styles.colorMuted,
styles.fontWeightNormal,
styles.textWrap,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
currentSearchKey,
]);

Expand Down
16 changes: 8 additions & 8 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.CONCIERGE_REPORT_ID,

Check warning on line 1039 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
conciergeReportIDOnyxConnect = value;
},
Expand All @@ -1044,7 +1044,7 @@

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({
key: ONYXKEYS.SESSION,

Check warning on line 1047 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
// When signed out, val is undefined
if (!value) {
Expand All @@ -1062,7 +1062,7 @@
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,

Check warning on line 1065 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
if (currentUserAccountID) {
currentUserPersonalDetails = value?.[currentUserAccountID] ?? undefined;
Expand All @@ -1074,7 +1074,7 @@

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,

Check warning on line 1077 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});
Expand All @@ -1082,7 +1082,7 @@
let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,

Check warning on line 1085 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
allPolicies = value;
Expand All @@ -1092,7 +1092,7 @@

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,

Check warning on line 1095 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
});
Expand All @@ -1100,7 +1100,7 @@
let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,

Check warning on line 1103 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
Expand Down Expand Up @@ -1136,14 +1136,14 @@

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({
key: ONYXKEYS.BETA_CONFIGURATION,

Check warning on line 1139 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => (betaConfiguration = value ?? {}),
});

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.TRANSACTION,

Check warning on line 1146 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
Expand Down Expand Up @@ -3001,7 +3001,7 @@
icons: Record<'Location' | 'ReceiptPlus', IconAsset>;
iouReportID: string | undefined;
policy: OnyxEntry<Policy>;
userBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod>;
userBillingGraceEndPeriods: OnyxCollection<BillingGraceEndPeriod>;
draftTransactionIDs: string[] | undefined;
amountOwed: OnyxEntry<number>;
ownerBillingGraceEndPeriod: OnyxEntry<number>;
Expand All @@ -3015,7 +3015,7 @@
icons,
iouReportID,
policy,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
Expand All @@ -3036,7 +3036,7 @@
if (
policy &&
policy.type !== CONST.POLICY.TYPE.PERSONAL &&
shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, amountOwed, ownerBillingGraceEndPeriod)
shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, amountOwed, ownerBillingGraceEndPeriod)
) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
Expand All @@ -3053,7 +3053,7 @@
if (!iouReportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, amountOwed, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, amountOwed, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -3066,7 +3066,7 @@
icon: icons.ReceiptPlus,
sentryLabel: CONST.SENTRY_LABEL.MORE_MENU.ADD_EXPENSE_UNREPORTED,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, amountOwed, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, amountOwed, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down Expand Up @@ -11223,7 +11223,7 @@
introSelected: OnyxEntry<IntroSelected>;
allTransactionDrafts: OnyxCollection<Transaction>;
activePolicy: OnyxEntry<Policy>;
userBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod>;
userBillingGraceEndPeriods: OnyxCollection<BillingGraceEndPeriod>;
amountOwed: OnyxEntry<number>;
isRestrictedToPreferredPolicy?: boolean;
preferredPolicyID?: string;
Expand All @@ -11237,7 +11237,7 @@
introSelected,
allTransactionDrafts,
activePolicy,
userBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods,
amountOwed,
isRestrictedToPreferredPolicy = false,
preferredPolicyID,
Expand Down Expand Up @@ -11304,7 +11304,7 @@
}

if (actionName === CONST.IOU.ACTION.CATEGORIZE) {
if (activePolicy && shouldRestrictUserBillableActions(activePolicy.id, userBillingGraceEndPeriodCollection, amountOwed)) {
if (activePolicy && shouldRestrictUserBillableActions(activePolicy.id, userBillingGraceEndPeriods, amountOwed)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(activePolicy.id));
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/libs/SubscriptionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ Onyx.connect({
callback: (value) => (ownerBillingGraceEndPeriodDeprecated = value),
});

let deprecatedUserBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod>;
let deprecatedUserBillingGraceEndPeriods: OnyxCollection<BillingGraceEndPeriod>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END,
callback: (value) => (deprecatedUserBillingGraceEndPeriodCollection = value),
callback: (value) => (deprecatedUserBillingGraceEndPeriods = value),
waitForCollectionCallback: true,
});

Expand Down Expand Up @@ -470,7 +470,7 @@ function doesUserHavePaymentCardAdded(userBillingFundID: number | undefined): bo
*/
function shouldRestrictUserBillableActions(
policyID: string,
userBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod> = deprecatedUserBillingGraceEndPeriodCollection,
userBillingGraceEndPeriods: OnyxCollection<BillingGraceEndPeriod> = deprecatedUserBillingGraceEndPeriods,
amountOwed: OnyxEntry<number> = privateAmountOwed,
ownerBillingGraceEndPeriod: OnyxEntry<number> = ownerBillingGraceEndPeriodDeprecated,
): boolean {
Expand All @@ -481,7 +481,7 @@ function shouldRestrictUserBillableActions(
// This logic will be executed if the user is a workspace's non-owner (normal user or admin).
// We should restrict the workspace's non-owner actions if it's member of a workspace where the owner is
// past due and is past its grace period end.
for (const userBillingGraceEndPeriodEntry of Object.entries(userBillingGraceEndPeriodCollection ?? {})) {
for (const userBillingGraceEndPeriodEntry of Object.entries(userBillingGraceEndPeriods ?? {})) {
const [entryKey, userBillingGracePeriodEnd] = userBillingGraceEndPeriodEntry;

if (userBillingGracePeriodEnd && isAfter(currentDate, fromUnixTime(userBillingGracePeriodEnd.value))) {
Expand Down
Loading
Loading