Skip to content

Commit 150a29a

Browse files
Fix typecheck: use 4-arg signature for shouldRestrictUserBillableActions
The call sites were passing a Policy object as a 5th argument, but the current main branch signature expects only 4 arguments (with policyID string as the first). Removed the redundant 5th argument from all call sites to match the expected function signature. Co-authored-by: Eugene Voloshchak <eVoloshchak@users.noreply.github.com>
1 parent 00778b8 commit 150a29a

3 files changed

Lines changed: 7 additions & 26 deletions

File tree

src/components/MoneyRequestHeaderSecondaryActions.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
354354
iconFill: isDuplicateActive ? undefined : theme.icon,
355355
value: CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DUPLICATE,
356356
onSelected: () => {
357-
if (
358-
defaultExpensePolicy &&
359-
shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, defaultExpensePolicy)
360-
) {
357+
if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
361358
dropdownMenuRef.current?.setIsMenuVisible(false);
362359
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id));
363360
return;

src/hooks/useExpenseActions.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
317317
iconFill: isDuplicateActive ? undefined : theme.icon,
318318
value: CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE_EXPENSE,
319319
onSelected: () => {
320-
if (
321-
defaultExpensePolicy &&
322-
shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, defaultExpensePolicy)
323-
) {
320+
if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
324321
onDuplicateReset?.();
325322
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id));
326323
return;
@@ -381,10 +378,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
381378
const isSourcePolicyValid = !!policy && isPolicyAccessible(policy, currentUserLogin ?? '');
382379
const targetPolicyForDuplicate = isSourcePolicyValid ? policy : defaultExpensePolicy;
383380

384-
if (
385-
targetPolicyForDuplicate &&
386-
shouldRestrictUserBillableActions(targetPolicyForDuplicate.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, targetPolicyForDuplicate)
387-
) {
381+
if (targetPolicyForDuplicate && shouldRestrictUserBillableActions(targetPolicyForDuplicate.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
388382
onDuplicateReset?.();
389383
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(targetPolicyForDuplicate.id));
390384
return;
@@ -563,7 +557,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
563557
if (!moneyRequestReport?.reportID) {
564558
return;
565559
}
566-
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) {
560+
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
567561
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
568562
return;
569563
}

src/hooks/useSearchBulkActions.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ function getRestrictedPolicyID(
103103
): string | undefined {
104104
return items
105105
.map((item) => item.policyID)
106-
.find(
107-
(policyID): policyID is string =>
108-
!!policyID &&
109-
shouldRestrictUserBillableActions(policyID, ownerBillingGracePeriodEnd, billingGracePeriods, amountOwed, allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]),
110-
);
106+
.find((policyID): policyID is string => !!policyID && shouldRestrictUserBillableActions(policyID, ownerBillingGracePeriodEnd, billingGracePeriods, amountOwed));
111107
}
112108

113109
type ShouldShowBulkDuplicateParams = {
@@ -1057,10 +1053,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
10571053
value: CONST.SEARCH.BULK_ACTION_TYPES.DUPLICATE,
10581054
shouldCloseModalOnSelect: true,
10591055
onSelected: () => {
1060-
if (
1061-
defaultExpensePolicy &&
1062-
shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, defaultExpensePolicy)
1063-
) {
1056+
if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
10641057
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id));
10651058
return;
10661059
}
@@ -1377,10 +1370,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
13771370
value: CONST.SEARCH.BULK_ACTION_TYPES.DUPLICATE,
13781371
shouldCloseModalOnSelect: true,
13791372
onSelected: () => {
1380-
if (
1381-
defaultExpensePolicy &&
1382-
shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, defaultExpensePolicy)
1383-
) {
1373+
if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) {
13841374
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id));
13851375
return;
13861376
}

0 commit comments

Comments
 (0)