diff --git a/src/components/GPSTripStateChecker/useUpdateGpsNotification/index.ios.ts b/src/components/GPSTripStateChecker/useUpdateGpsNotification/index.ios.ts index 8ecafc70f9d2..bd8a7100c9d9 100644 --- a/src/components/GPSTripStateChecker/useUpdateGpsNotification/index.ios.ts +++ b/src/components/GPSTripStateChecker/useUpdateGpsNotification/index.ios.ts @@ -1,4 +1,5 @@ import {useEffect, useRef} from 'react'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -34,6 +35,7 @@ function useUpdateGpsNotificationOnLanguageChange() { function useUpdateGpsNotificationOnUnitChange() { const {translate} = useLocalize(); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED); const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END); @@ -41,7 +43,14 @@ function useUpdateGpsNotificationOnUnitChange() { const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`); const defaultExpensePolicy = useDefaultExpensePolicy(); - const shouldUseDefaultExpensePolicy = shouldUseDefaultExpensePolicyUtil(CONST.IOU.TYPE.CREATE, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd); + const shouldUseDefaultExpensePolicy = shouldUseDefaultExpensePolicyUtil( + CONST.IOU.TYPE.CREATE, + defaultExpensePolicy, + amountOwed, + userBillingGracePeriodEnds, + ownerBillingGracePeriodEnd, + currentUserPersonalDetails.accountID, + ); const unit = DistanceRequestUtils.getRate({transaction, policy: shouldUseDefaultExpensePolicy ? defaultExpensePolicy : undefined}).unit; diff --git a/src/components/MoneyRequestHeaderSecondaryActions.tsx b/src/components/MoneyRequestHeaderSecondaryActions.tsx index d6a774d8ae29..6553228b9538 100644 --- a/src/components/MoneyRequestHeaderSecondaryActions.tsx +++ b/src/components/MoneyRequestHeaderSecondaryActions.tsx @@ -341,7 +341,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money icon: expensifyIcons.ArrowSplit, value: CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.SPLIT, onSelected: () => { - initSplitExpense(transaction, policy, report); + initSplitExpense(transaction, policy, report, accountID); }, }, [CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.MERGE]: { diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0e24f5e95356..ad996a6c9a20 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -956,7 +956,7 @@ function MoneyRequestView({ } if (shouldShowSplitIndicator && isSplitAvailable) { - initSplitExpense(transaction, policy, transactionThreadReport); + initSplitExpense(transaction, policy, transactionThreadReport, currentUserAccountIDParam); return; } diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index 3e7cb0259d5a..db9b3620d5a8 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -141,7 +141,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac const transactionReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${splitExpenseEditTransaction.reportID}`]; const selfDMReport = isSelfDM(report) ? report : allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`]; const splitExpenseEditTransactionReport = transactionReport ?? selfDMReport; - initSplitExpense(splitExpenseEditTransaction, policy, splitExpenseEditTransactionReport, {navigateToEditSplitExpense: true}); + initSplitExpense(splitExpenseEditTransaction, policy, splitExpenseEditTransactionReport, currentUserPersonalDetails.accountID, {navigateToEditSplitExpense: true}); return { action: 'redirected', }; diff --git a/src/hooks/useExpenseActions.ts b/src/hooks/useExpenseActions.ts index f9e92ea9c98a..290718a7368a 100644 --- a/src/hooks/useExpenseActions.ts +++ b/src/hooks/useExpenseActions.ts @@ -268,6 +268,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic amountOwed, ownerBillingGracePeriodEnd, lastDistanceExpenseType, + currentUserAccountID: accountID, }); const expensifyIcons = useMemoizedLazyExpensifyIcons([ @@ -297,7 +298,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic if (transactions.length !== 1) { return; } - initSplitExpense(currentTransaction, policy, moneyRequestReport); + initSplitExpense(currentTransaction, policy, moneyRequestReport, accountID); }, }, [CONST.REPORT.SECONDARY_ACTIONS.MERGE]: { @@ -318,7 +319,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic iconFill: isDuplicateActive ? undefined : theme.icon, value: CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE_EXPENSE, onSelected: () => { - if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, accountID)) { onDuplicateReset?.(); Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id)); return; @@ -379,7 +380,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic const isSourcePolicyValid = !!policy && isPolicyAccessible(policy, currentUserLogin ?? ''); const targetPolicyForDuplicate = isSourcePolicyValid ? policy : defaultExpensePolicy; - if (targetPolicyForDuplicate && shouldRestrictUserBillableActions(targetPolicyForDuplicate, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (targetPolicyForDuplicate && shouldRestrictUserBillableActions(targetPolicyForDuplicate, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, accountID)) { onDuplicateReset?.(); Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(targetPolicyForDuplicate.id)); return; diff --git a/src/hooks/useParticipantSubmission.ts b/src/hooks/useParticipantSubmission.ts index ba7f98fbcbc0..fe1dd0ec9fc6 100644 --- a/src/hooks/useParticipantSubmission.ts +++ b/src/hooks/useParticipantSubmission.ts @@ -98,7 +98,7 @@ function useParticipantSubmission({ iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && - !shouldRestrictUserBillableActions(activePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed); + !shouldRestrictUserBillableActions(activePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserPersonalDetails.accountID); const dataRef = useRef({ allPolicies, diff --git a/src/hooks/useSearchBulkActions.ts b/src/hooks/useSearchBulkActions.ts index afb8f75d4194..e4ec2edd1929 100644 --- a/src/hooks/useSearchBulkActions.ts +++ b/src/hooks/useSearchBulkActions.ts @@ -1226,7 +1226,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { value: CONST.SEARCH.BULK_ACTION_TYPES.DUPLICATE, shouldCloseModalOnSelect: true, onSelected: () => { - if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id)); return; } @@ -1573,7 +1573,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { icon: expensifyIcons.ArrowSplit, value: CONST.SEARCH.BULK_ACTION_TYPES.SPLIT, onSelected: () => { - initSplitExpense(firstTransaction, firstTransactionPolicy, firstTransactionReport); + initSplitExpense(firstTransaction, firstTransactionPolicy, firstTransactionReport, accountID); }, }); } @@ -1586,7 +1586,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) { value: CONST.SEARCH.BULK_ACTION_TYPES.DUPLICATE, shouldCloseModalOnSelect: true, onSelected: () => { - if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (defaultExpensePolicy && shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, accountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(defaultExpensePolicy.id)); return; } diff --git a/src/hooks/useSelectedTransactionsActions.ts b/src/hooks/useSelectedTransactionsActions.ts index a83fe54877a1..e340cee5d5bd 100644 --- a/src/hooks/useSelectedTransactionsActions.ts +++ b/src/hooks/useSelectedTransactionsActions.ts @@ -486,7 +486,7 @@ function useSelectedTransactionsActions({ icon: expensifyIcons.ArrowSplit, value: SPLIT, onSelected: () => { - initSplitExpense(firstTransaction, policy, report); + initSplitExpense(firstTransaction, policy, report, currentUserAccountID); }, }); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 50d1b0b63e39..6faa15662367 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2948,6 +2948,7 @@ type GetAddExpenseDropdownOptionsParams = { iouRequestBackToReport?: string; unreportedExpenseBackToReport?: string; lastDistanceExpenseType?: IOURequestType; + currentUserAccountID?: number; }; function getAddExpenseDropdownOptions({ @@ -2962,6 +2963,7 @@ function getAddExpenseDropdownOptions({ iouRequestBackToReport, unreportedExpenseBackToReport, lastDistanceExpenseType, + currentUserAccountID, }: GetAddExpenseDropdownOptionsParams): Array>> { return [ { @@ -2973,7 +2975,11 @@ function getAddExpenseDropdownOptions({ if (!iouReportID) { return; } - if (policy && policy.type !== CONST.POLICY.TYPE.PERSONAL && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if ( + policy && + policy.type !== CONST.POLICY.TYPE.PERSONAL && + shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID) + ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -2989,7 +2995,7 @@ function getAddExpenseDropdownOptions({ if (!iouReportID) { return; } - if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -3002,7 +3008,7 @@ function getAddExpenseDropdownOptions({ icon: icons.ReceiptPlus, sentryLabel: CONST.SENTRY_LABEL.MORE_MENU.ADD_EXPENSE_EXISTING, onSelected: () => { - if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } @@ -11402,7 +11408,7 @@ function createDraftTransactionAndNavigateToParticipantSelector({ } if (actionName === CONST.IOU.ACTION.CATEGORIZE) { - if (activePolicy && shouldRestrictUserBillableActions(activePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (activePolicy && shouldRestrictUserBillableActions(activePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(activePolicy.id)); return; } diff --git a/src/libs/SubscriptionUtils.ts b/src/libs/SubscriptionUtils.ts index 87e2ba49476b..bdeeb14e4039 100644 --- a/src/libs/SubscriptionUtils.ts +++ b/src/libs/SubscriptionUtils.ts @@ -1,7 +1,7 @@ import {differenceInSeconds, fromUnixTime, isAfter, isBefore} from 'date-fns'; import {fromZonedTime} from 'date-fns-tz'; -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type {LocalizedTranslate} from '@components/LocaleContextProvider'; import type {PreferredCurrency} from '@hooks/usePreferredCurrency'; @@ -481,7 +481,7 @@ function shouldRestrictUserBillableActions( ownerBillingGracePeriodEnd: OnyxEntry, userBillingGracePeriodEnds: OnyxCollection, amountOwed: OnyxEntry, - currentUserAccountID: number = deprecatedCurrentUserAccountID, + currentUserAccountID: number | undefined = deprecatedCurrentUserAccountID, ): boolean { const currentDate = new Date(); diff --git a/src/libs/actions/IOU/MoneyRequest.ts b/src/libs/actions/IOU/MoneyRequest.ts index 8956276d14d7..733b145133d2 100644 --- a/src/libs/actions/IOU/MoneyRequest.ts +++ b/src/libs/actions/IOU/MoneyRequest.ts @@ -512,7 +512,7 @@ function handleMoneyRequestStepScanParticipants({ // If there was no reportID, then that means the user started this flow from the global + menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - if (shouldUseDefaultExpensePolicy(iouType, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd)) { + if (shouldUseDefaultExpensePolicy(iouType, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, currentUserAccountID)) { const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || isAutoReporting; const targetReport = shouldAutoReport ? getPolicyExpenseChat(currentUserAccountID, defaultExpensePolicy?.id) : selfDMReport; const transactionReportID = isSelfDM(targetReport) ? CONST.REPORT.UNREPORTED_REPORT_ID : targetReport?.reportID; @@ -789,7 +789,7 @@ function handleMoneyRequestStepDistanceNavigation({ // If there was no reportID, then that means the user started this flow from the global menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. - if (defaultExpensePolicy && shouldUseDefaultExpensePolicy(iouType, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd)) { + if (defaultExpensePolicy && shouldUseDefaultExpensePolicy(iouType, defaultExpensePolicy, amountOwed, userBillingGracePeriodEnds, ownerBillingGracePeriodEnd, currentUserAccountID)) { const shouldAutoReport = !!defaultExpensePolicy?.autoReporting || isAutoReporting; const targetReport = shouldAutoReport ? getPolicyExpenseChat(currentUserAccountID, defaultExpensePolicy?.id) : selfDMReport; const isSelfDMReport = isSelfDM(targetReport); diff --git a/src/libs/actions/IOU/PayMoneyRequest.ts b/src/libs/actions/IOU/PayMoneyRequest.ts index 77dd0e549121..f03b3bed864b 100644 --- a/src/libs/actions/IOU/PayMoneyRequest.ts +++ b/src/libs/actions/IOU/PayMoneyRequest.ts @@ -766,7 +766,7 @@ function payMoneyRequest(params: PayMoneyRequestFunctionParams) { if ( chatReport.policyID && policyForBillingRestriction && - shouldRestrictUserBillableActions(policyForBillingRestriction, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed) + shouldRestrictUserBillableActions(policyForBillingRestriction, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID) ) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(chatReport.policyID)); return; diff --git a/src/libs/actions/SplitExpenses.ts b/src/libs/actions/SplitExpenses.ts index 3d255b4d34e9..24df3351bca8 100644 --- a/src/libs/actions/SplitExpenses.ts +++ b/src/libs/actions/SplitExpenses.ts @@ -90,13 +90,14 @@ function initSplitExpense( transaction: OnyxEntry, policy: OnyxEntry, report: OnyxEntry, + currentUserAccountID: number | undefined, {navigateToEditSplitExpense = false}: {navigateToEditSplitExpense?: boolean} = {}, ): void { if (!transaction) { return; } - if (!!policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed)) { + if (!!policy && shouldRestrictUserBillableActions(policy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID)) { Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id)); return; } diff --git a/src/libs/shouldUseDefaultExpensePolicy.ts b/src/libs/shouldUseDefaultExpensePolicy.ts index 4b775610c4cc..68e454f0260c 100644 --- a/src/libs/shouldUseDefaultExpensePolicy.ts +++ b/src/libs/shouldUseDefaultExpensePolicy.ts @@ -11,12 +11,13 @@ function shouldUseDefaultExpensePolicy( amountOwed: OnyxEntry, userBillingGracePeriodEnds: OnyxCollection, ownerBillingGracePeriodEnd: OnyxEntry, + currentUserAccountID?: number, ) { return ( iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(defaultExpensePolicy) && defaultExpensePolicy?.isPolicyExpenseChatEnabled && - !shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed) + !shouldRestrictUserBillableActions(defaultExpensePolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, currentUserAccountID) ); } diff --git a/src/pages/iou/request/step/IOURequestStepReport/hooks/useCreateReportRestrictionCheck.ts b/src/pages/iou/request/step/IOURequestStepReport/hooks/useCreateReportRestrictionCheck.ts index c6ee88565824..a356e89a01e4 100644 --- a/src/pages/iou/request/step/IOURequestStepReport/hooks/useCreateReportRestrictionCheck.ts +++ b/src/pages/iou/request/step/IOURequestStepReport/hooks/useCreateReportRestrictionCheck.ts @@ -1,6 +1,7 @@ import type {OnyxEntry} from 'react-native-onyx'; import useOnyx from '@hooks/useOnyx'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; +import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Policy, Session} from '@src/types/onyx'; @@ -17,7 +18,7 @@ function useCreateReportRestrictionCheck(session: OnyxEntry): (restrict if (!restrictionPolicy) { return false; } - return shouldRestrictUserBillableActions(restrictionPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, session?.accountID); + return shouldRestrictUserBillableActions(restrictionPolicy, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, session?.accountID ?? CONST.DEFAULT_NUMBER_ID); }; } diff --git a/tests/actions/IOU/MoneyRequestTest.ts b/tests/actions/IOU/MoneyRequestTest.ts index 6802c1ee9321..32cc57adb9bb 100644 --- a/tests/actions/IOU/MoneyRequestTest.ts +++ b/tests/actions/IOU/MoneyRequestTest.ts @@ -1643,7 +1643,7 @@ describe('MoneyRequest', () => { isPolicyExpenseChatEnabled: true, }; - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined)).toBe(true); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(true); }); it('should return false when iouType is not CREATE', () => { @@ -1653,9 +1653,9 @@ describe('MoneyRequest', () => { isPolicyExpenseChatEnabled: true, }; - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.SUBMIT, policy, 0, undefined, undefined)).toBe(false); - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.TRACK, policy, 0, undefined, undefined)).toBe(false); - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.SPLIT, policy, 0, undefined, undefined)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.SUBMIT, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.TRACK, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.SPLIT, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(false); }); it('should return false when policy is not a paid group policy', () => { @@ -1665,7 +1665,7 @@ describe('MoneyRequest', () => { isPolicyExpenseChatEnabled: true, }; - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(false); }); it('should return false when isPolicyExpenseChatEnabled is false', () => { @@ -1675,15 +1675,15 @@ describe('MoneyRequest', () => { isPolicyExpenseChatEnabled: false, }; - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 0, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(false); }); it('should return false when policy is undefined', () => { - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, undefined, 0, undefined, undefined)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, undefined, 0, undefined, undefined, currentUserAccountID)).toBe(false); }); it('should return false when policy is null', () => { - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, null, 0, undefined, undefined)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, null, 0, undefined, undefined, currentUserAccountID)).toBe(false); }); it('should handle amountOwed being undefined', () => { @@ -1693,7 +1693,7 @@ describe('MoneyRequest', () => { isPolicyExpenseChatEnabled: true, }; - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, undefined, undefined, undefined)).toBe(true); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, undefined, undefined, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID)).toBe(true); }); it('should pass ownerBillingGracePeriodEnd through to shouldRestrictUserBillableActions', async () => { @@ -1708,7 +1708,7 @@ describe('MoneyRequest', () => { await Onyx.set(ONYXKEYS.SESSION, {accountID: TEST_USER_ACCOUNT_ID}); await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, policy); - expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 100, undefined, pastDate)).toBe(false); + expect(shouldUseDefaultExpensePolicy(CONST.IOU.TYPE.CREATE, policy, 100, undefined, pastDate, TEST_USER_ACCOUNT_ID)).toBe(false); await Onyx.clear(); }); diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index fc24abdb46e0..197f0b27cd2e 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -4858,7 +4858,7 @@ describe('initSplitExpense', () => { reportID: '456', }; - initSplitExpense(transaction, undefined, undefined); + initSplitExpense(transaction, undefined, undefined, CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); const draftTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`); @@ -4883,7 +4883,7 @@ describe('initSplitExpense', () => { }); it('should not initialize split expense for null transaction', async () => { const transaction: Transaction | undefined = undefined; - initSplitExpense(transaction, undefined, undefined); + initSplitExpense(transaction, undefined, undefined, CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); expect(transaction).toBeFalsy(); @@ -4907,7 +4907,7 @@ describe('initSplitExpense', () => { reportID: '456', }; - initSplitExpense(transaction, undefined, undefined); + initSplitExpense(transaction, undefined, undefined, CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); const draftTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`); @@ -4976,7 +4976,7 @@ describe('initSplitExpense', () => { reportID: '456', }; - initSplitExpense(transaction, policy, undefined); + initSplitExpense(transaction, policy, undefined, policy.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); const draftTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`); @@ -5049,7 +5049,7 @@ describe('initSplitExpense', () => { await waitForBatchedUpdates(); // When the user initiates a split on the remaining transaction - initSplitExpense(remainingTransaction, undefined, undefined); + initSplitExpense(remainingTransaction, undefined, undefined, CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); // Then a fresh split is started keyed by the remaining transaction (2 new splits) @@ -5110,7 +5110,7 @@ describe('initSplitExpense', () => { await waitForBatchedUpdates(); // When the user opens the edit-splits flow from one of the children - initSplitExpense(secondChildTransaction, undefined, undefined); + initSplitExpense(secondChildTransaction, undefined, undefined, CONST.DEFAULT_NUMBER_ID); await waitForBatchedUpdates(); // Then the edit-splits draft is keyed by the original transaction and rebuilt from the existing children