diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 2a2887ba5dfc..d0aace14ff25 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -62,10 +62,10 @@ import type {PerDiemExpenseInformation} from './PerDiem'; import type {CreateDistanceRequestInformation} from './Split'; import type {CreateTrackExpenseParams} from './TrackExpense'; -import {getAllReports, getAllTransactions} from '.'; +import {getAllReports, getAllTransactions, getPolicyTags} from '.'; import {getCleanUpTransactionThreadReportOnyxData} from './DeleteMoneyRequest'; import {getMoneyRequestParticipantsFromReport} from './MoneyRequest'; -import {submitPerDiemExpense} from './PerDiem'; +import {getPerDiemExpensePolicyID, submitPerDiemExpense} from './PerDiem'; import {createDistanceRequest} from './Split'; import {requestMoney, trackExpense} from './TrackExpense'; @@ -729,6 +729,9 @@ function createExpenseByType({ return createDistanceRequest(distanceParams); } case CONST.SEARCH.TRANSACTION_TYPE.PER_DIEM: { + const earlyPolicyID = getPerDiemExpensePolicyID(params); + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const perDiemParams: PerDiemExpenseInformation = { ...params, transactionParams: { @@ -740,6 +743,7 @@ function createExpenseByType({ customUnitPolicyID, isTrackIntentUser, formatPhoneNumber, + policyTags, }; return submitPerDiemExpense(perDiemParams); } diff --git a/src/libs/actions/IOU/PerDiem.ts b/src/libs/actions/IOU/PerDiem.ts index 4a854e1bd7e8..d9c5bd066b47 100644 --- a/src/libs/actions/IOU/PerDiem.ts +++ b/src/libs/actions/IOU/PerDiem.ts @@ -62,7 +62,7 @@ import type BasePolicyParams from './types/BasePolicyParams'; import type BaseTransactionParams from './types/BaseTransactionParams'; import type RequestMoneyParticipantParams from './types/RequestMoneyParticipantParams'; -import {getAllPersonalDetails, getAllReports, getPolicyTags} from '.'; +import {getAllPersonalDetails, getAllReports} from '.'; import { buildMinimalTransactionForFormula, buildOnyxDataForMoneyRequest, @@ -229,6 +229,8 @@ type PerDiemExpenseInformation = { recentlyUsedParams?: RecentlyUsedParams; transactionParams: PerDiemExpenseTransactionParams; existingIOUReport?: OnyxEntry; + /** The policy's tags, keyed the same way `getPolicyTags()` would return for this expense's policyID. */ + policyTags: OnyxTypes.PolicyTagLists; isASAPSubmitBetaEnabled: boolean; currentUserAccountIDParam: number; currentUserEmailParam: string; @@ -257,6 +259,8 @@ type PerDiemExpenseInformationParams = { recentlyUsedParams?: RecentlyUsedParams; existingIOUReport?: OnyxEntry; moneyRequestReportID?: string; + /** The policy's tags, keyed the same way `getPolicyTags()` would return for this expense's policyID. */ + policyTags: OnyxTypes.PolicyTagLists; isASAPSubmitBetaEnabled: boolean; currentUserAccountIDParam: number; currentUserEmailParam: string; @@ -303,6 +307,50 @@ type PerDiemExpenseInformationForSelfDMResult = { >; }; +type GetPerDiemExpensePolicyIDParams = { + report: OnyxEntry; + participantParams: RequestMoneyParticipantParams; + existingIOUReport?: OnyxEntry; + betas: OnyxEntry; + currentUserAccountIDParam: number; +}; + +/** + * Resolves the policyID that `getPerDiemExpenseInformation`'s iouReport will end up with, without waiting for its + * STEP 1/STEP 2 (chatReport/iouReport resolution) to run. It is read-only and does not build any optimistic report or + * transaction. Keep in sync with STEP 1/STEP 2 in `getPerDiemExpenseInformation` (and the chat report/moneyRequestReportID + * resolution in `submitPerDiemExpense`) if their resolution order changes. + */ +function getPerDiemExpensePolicyID({report, participantParams, existingIOUReport, betas, currentUserAccountIDParam}: GetPerDiemExpensePolicyIDParams): string | undefined { + const {payeeAccountID = currentUserAccountIDParam, participant} = participantParams; + const payerAccountID = Number(participant.accountID); + const isPolicyExpenseChat = participant.isPolicyExpenseChat; + const allReports = getAllReports(); + + const isMoneyRequestReport = isMoneyRequestReportReportUtils(report); + const parentChatReport = isMoneyRequestReport ? getReportOrDraftReport(report?.chatReportID) : report; + const moneyRequestReportID = isMoneyRequestReport ? report?.reportID : ''; + + const parentChatReportCandidate = parentChatReport?.reportID ? parentChatReport : null; + const policyExpenseChatCandidate = isPolicyExpenseChat ? (allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${participant.reportID}`] ?? null) : null; + const chatReport = parentChatReportCandidate ?? policyExpenseChatCandidate ?? getChatByParticipants([payerAccountID, payeeAccountID]) ?? null; + + let iouReport: OnyxInputValue = null; + if (existingIOUReport) { + iouReport = existingIOUReport; + } else if (moneyRequestReportID) { + iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReportID}`] ?? null; + } else if (chatReport) { + iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`] ?? null; + } + const shouldCreateNew = shouldCreateNewMoneyRequestReportReportUtils(iouReport, chatReport, false, betas); + + if (iouReport && !shouldCreateNew) { + return iouReport.policyID; + } + return isPolicyExpenseChat ? (chatReport?.policyID ?? CONST.POLICY.OWNER_EMAIL_FAKE) : undefined; +} + /** * Gathers all the data needed to submit a per diem expense. It attempts to find existing reports, iouReports, and receipts. If it doesn't find them, then * it creates optimistic versions of them and uses those instead @@ -316,6 +364,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI recentlyUsedParams = {}, existingIOUReport: existingIOUReportParam, moneyRequestReportID = '', + policyTags, isASAPSubmitBetaEnabled, currentUserAccountIDParam, currentUserEmailParam, @@ -456,9 +505,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI optimisticTransaction.hasEReceipt = true; const optimisticPolicyRecentlyUsedCategories = mergePolicyRecentlyUsedCategories(category, policyRecentlyUsedCategories); const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({ - // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook - - policyTags: getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${iouReport.policyID}`] ?? {}, + policyTags, policyRecentlyUsedTags, transactionTags: tag, }); @@ -929,6 +976,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf recentlyUsedParams = {}, transactionParams, existingIOUReport, + policyTags, isASAPSubmitBetaEnabled, currentUserAccountIDParam, currentUserEmailParam, @@ -987,6 +1035,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf transactionParams, existingIOUReport, moneyRequestReportID, + policyTags, isASAPSubmitBetaEnabled, currentUserAccountIDParam, currentUserEmailParam, @@ -1164,6 +1213,7 @@ export { addSubrate, computePerDiemExpenseAmount, isValidPerDiemExpenseAmount, + getPerDiemExpensePolicyID, getPerDiemExpenseInformation, submitPerDiemExpense, submitPerDiemExpenseForSelfDM, diff --git a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts index d5e394ed3b22..1fd7009d8480 100644 --- a/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts +++ b/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts @@ -56,8 +56,9 @@ import { import {resolveChatTargetForSubmitCleanup} from '@pages/iou/request/step/resolveChatTarget'; +import {getPolicyTags} from '@userActions/IOU'; import {isOneToTwoTransactionTransition} from '@userActions/IOU/PendingNewTransactions'; -import {submitPerDiemExpenseForSelfDM, submitPerDiemExpense as submitPerDiemExpenseIOUActions} from '@userActions/IOU/PerDiem'; +import {getPerDiemExpensePolicyID, submitPerDiemExpenseForSelfDM, submitPerDiemExpense as submitPerDiemExpenseIOUActions} from '@userActions/IOU/PerDiem'; import {getReceiverType, sendInvoice} from '@userActions/IOU/SendInvoice'; import {sendMoneyElsewhere, sendMoneyWithWallet} from '@userActions/IOU/SendMoney'; import {createDistanceRequest as createDistanceRequestIOUActions, splitBill, splitBillAndOpenReport, startSplitBill} from '@userActions/IOU/Split'; @@ -613,14 +614,24 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { ); const activeReportID = isExpenseReport ? report?.reportID : chatReportID; + const perDiemParticipantParams = { + payeeEmail: currentUserPersonalDetails.login, + payeeAccountID: currentUserPersonalDetails.accountID, + participant, + }; + const earlyPolicyID = getPerDiemExpensePolicyID({ + report, + participantParams: perDiemParticipantParams, + existingIOUReport: undefined, + betas, + currentUserAccountIDParam: currentUserPersonalDetails.accountID, + }); + const perDiemExpensePolicyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = submitPerDiemExpenseIOUActions({ getCurrencyDecimals, report, - participantParams: { - payeeEmail: currentUserPersonalDetails.login, - payeeAccountID: currentUserPersonalDetails.accountID, - participant, - }, + participantParams: perDiemParticipantParams, policyParams: { policy, policyTagList: policyTags, @@ -643,6 +654,7 @@ function useExpenseSubmission(params: UseExpenseSubmissionParams) { attendees: transaction.comment?.attendees, isFromGlobalCreate: getIsFromGlobalCreate(transaction), }, + policyTags: perDiemExpensePolicyTags, isASAPSubmitBetaEnabled, currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.login ?? '', diff --git a/tests/actions/IOU/PerDiemTest.ts b/tests/actions/IOU/PerDiemTest.ts index 1dc8139015e5..da386e2fe0fb 100644 --- a/tests/actions/IOU/PerDiemTest.ts +++ b/tests/actions/IOU/PerDiemTest.ts @@ -1,5 +1,15 @@ +import {getPolicyTags} from '@libs/actions/IOU'; import type {PerDiemExpenseTransactionParams} from '@libs/actions/IOU/PerDiem'; -import {addSubrate, clearSubrates, computePerDiemExpenseAmount, getPerDiemExpenseInformation, removeSubrate, submitPerDiemExpense, updateSubrate} from '@libs/actions/IOU/PerDiem'; +import { + addSubrate, + clearSubrates, + computePerDiemExpenseAmount, + getPerDiemExpenseInformation, + getPerDiemExpensePolicyID, + removeSubrate, + submitPerDiemExpense, + updateSubrate, +} from '@libs/actions/IOU/PerDiem'; import type RequestMoneyParticipantParams from '@libs/actions/IOU/types/RequestMoneyParticipantParams'; import CONST from '@src/CONST'; @@ -313,12 +323,26 @@ describe('PerDiem', () => { }, }; + const parentChatReport = {} as OnyxEntry; + const participantParams = mockParticipantParams as unknown as RequestMoneyParticipantParams; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: parentChatReport, + participantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: 123, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ + parentChatReport, getCurrencyDecimals: getCurrencyDecimalsLocal, - parentChatReport: {} as OnyxEntry, transactionParams: mockTransactionParams, - participantParams: mockParticipantParams as unknown as RequestMoneyParticipantParams, + participantParams, recentlyUsedParams: {}, + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: 123, currentUserEmailParam: 'payee@example.com', @@ -405,14 +429,27 @@ describe('PerDiem', () => { }; // When: Call getPerDiemExpenseInformation + const parentChatReport = {} as OnyxEntry; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: parentChatReport, + participantParams: mockParticipantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: 123, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ + parentChatReport, getCurrencyDecimals: getCurrencyDecimalsLocal, - parentChatReport: {} as OnyxEntry, transactionParams: mockTransactionParams, participantParams: mockParticipantParams, policyParams: mockPolicyParams, recentlyUsedParams: {}, moneyRequestReportID: '1', + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', @@ -499,12 +536,23 @@ describe('PerDiem', () => { participant: {accountID: 123, login: 'payee@example.com'}, }; + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: undefined, + participantParams: mockParticipantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: 123, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ getCurrencyDecimals: getCurrencyDecimalsLocal, parentChatReport: undefined, transactionParams: mockTransactionParams, participantParams: mockParticipantParams, recentlyUsedParams: {}, + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: 123, currentUserEmailParam: 'payee@example.com', @@ -603,12 +651,26 @@ describe('PerDiem', () => { }; // When: Call getPerDiemExpenseInformation with existing chat report + const parentChatReport = existingChatReport as OnyxEntry; + const participantParams = mockParticipantParams as RequestMoneyParticipantParams; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: parentChatReport, + participantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: 123, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ + parentChatReport, getCurrencyDecimals: getCurrencyDecimalsLocal, - parentChatReport: existingChatReport as OnyxEntry, transactionParams: mockTransactionParams as PerDiemExpenseTransactionParams, - participantParams: mockParticipantParams as RequestMoneyParticipantParams, + participantParams, recentlyUsedParams: {}, + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', @@ -694,13 +756,27 @@ describe('PerDiem', () => { }; // When: Call getPerDiemExpenseInformation for policy expense chat + const parentChatReport = {} as OnyxEntry; + const participantParams = mockParticipantParams as RequestMoneyParticipantParams; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: parentChatReport, + participantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: 123, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ + parentChatReport, getCurrencyDecimals: getCurrencyDecimalsLocal, - parentChatReport: {} as OnyxEntry, transactionParams: mockTransactionParams as PerDiemExpenseTransactionParams, - participantParams: mockParticipantParams as RequestMoneyParticipantParams, + participantParams, policyParams: mockPolicyParams, recentlyUsedParams: {}, + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: 123, currentUserEmailParam: 'existing@example.com', @@ -753,21 +829,35 @@ describe('PerDiem', () => { await waitForBatchedUpdates(); // When submitting a per diem expense + const report = { + reportID: '1', + iouReportID, + }; + const participantParams = { + payeeEmail: currentUserPersonalDetails.login, + payeeAccountID: currentUserPersonalDetails.accountID, + participant: {}, + }; + const betas = [CONST.BETAS.ALL]; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report, + participantParams, + existingIOUReport: undefined, + betas, + currentUserAccountIDParam: currentUserPersonalDetails.accountID, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + submitPerDiemExpense({ getCurrencyDecimals: getCurrencyDecimalsLocal, currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.login ?? '', hasViolations: false, isASAPSubmitBetaEnabled: false, - participantParams: { - payeeEmail: currentUserPersonalDetails.login, - payeeAccountID: currentUserPersonalDetails.accountID, - participant: {}, - }, - report: { - reportID: '1', - iouReportID, - }, + participantParams, + report, transactionParams: { created: DateUtils.getDBTime(), currency: CONST.CURRENCY.USD, @@ -786,8 +876,9 @@ describe('PerDiem', () => { policyRecentlyUsedTags, }, quickAction: undefined, - betas: [CONST.BETAS.ALL], + betas, personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, + policyTags, formatPhoneNumber, delegateAccountID: undefined, isTrackIntentUser: false, @@ -826,21 +917,36 @@ describe('PerDiem', () => { type: CONST.POLICY.TYPE.TEAM, }); await waitForBatchedUpdates(); + + const report = { + reportID: '1', + iouReportID, + }; + const participantParams = { + payeeEmail: currentUserPersonalDetails.login, + payeeAccountID: currentUserPersonalDetails.accountID, + participant: {}, + }; + const betas = [CONST.BETAS.ALL]; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report, + participantParams, + existingIOUReport: undefined, + betas, + currentUserAccountIDParam: currentUserPersonalDetails.accountID, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + submitPerDiemExpense({ getCurrencyDecimals: getCurrencyDecimalsLocal, currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.login ?? '', hasViolations: false, isASAPSubmitBetaEnabled: false, - participantParams: { - payeeEmail: currentUserPersonalDetails.login, - payeeAccountID: currentUserPersonalDetails.accountID, - participant: {}, - }, - report: { - reportID: '1', - iouReportID, - }, + participantParams, + report, transactionParams: { created: DateUtils.getDBTime(), currency: CONST.CURRENCY.USD, @@ -857,8 +963,9 @@ describe('PerDiem', () => { policy: {...createRandomPolicy(1)}, }, quickAction: undefined, - betas: [CONST.BETAS.ALL], + betas, personalDetails: {[RORY_ACCOUNT_ID]: {accountID: RORY_ACCOUNT_ID, login: RORY_EMAIL}}, + policyTags, optimisticTransactionID, formatPhoneNumber, delegateAccountID: undefined, @@ -915,19 +1022,33 @@ describe('PerDiem', () => { }; // When calling getPerDiemExpenseInformation with personalDetails + const parentChatReport = {} as OnyxEntry; + const participantParams = { + payeeAccountID: RORY_ACCOUNT_ID, + payeeEmail: RORY_EMAIL, + participant: { + accountID: RORY_ACCOUNT_ID, + login: RORY_EMAIL, + }, + } as unknown as RequestMoneyParticipantParams; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report: parentChatReport, + participantParams, + existingIOUReport: undefined, + betas: [CONST.BETAS.ALL], + currentUserAccountIDParam: RORY_ACCOUNT_ID, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + const result = getPerDiemExpenseInformation({ + parentChatReport, getCurrencyDecimals: getCurrencyDecimalsLocal, - parentChatReport: {} as OnyxEntry, transactionParams: mockTransactionParams, - participantParams: { - payeeAccountID: RORY_ACCOUNT_ID, - payeeEmail: RORY_EMAIL, - participant: { - accountID: RORY_ACCOUNT_ID, - login: RORY_EMAIL, - }, - } as unknown as RequestMoneyParticipantParams, + participantParams, recentlyUsedParams: {}, + policyTags, isASAPSubmitBetaEnabled: false, currentUserAccountIDParam: RORY_ACCOUNT_ID, currentUserEmailParam: RORY_EMAIL, @@ -971,21 +1092,35 @@ describe('PerDiem', () => { }; // When submitting a per diem expense with personalDetails + const report = { + reportID: '1', + iouReportID, + }; + const participantParams = { + payeeEmail: currentUserPersonalDetails.login, + payeeAccountID: currentUserPersonalDetails.accountID, + participant: {}, + }; + const betas = [CONST.BETAS.ALL]; + + const earlyPolicyID = getPerDiemExpensePolicyID({ + report, + participantParams, + existingIOUReport: undefined, + betas, + currentUserAccountIDParam: currentUserPersonalDetails.accountID, + }); + // TODO: Replace getPolicyTags (https://github.com/Expensify/App/issues/72721) with useOnyx hook + const policyTags = getPolicyTags()?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${earlyPolicyID}`] ?? {}; + submitPerDiemExpense({ getCurrencyDecimals: getCurrencyDecimalsLocal, currentUserAccountIDParam: currentUserPersonalDetails.accountID, currentUserEmailParam: currentUserPersonalDetails.login ?? '', hasViolations: false, isASAPSubmitBetaEnabled: false, - participantParams: { - payeeEmail: currentUserPersonalDetails.login, - payeeAccountID: currentUserPersonalDetails.accountID, - participant: {}, - }, - report: { - reportID: '1', - iouReportID, - }, + participantParams, + report, transactionParams: { created: DateUtils.getDBTime(), currency: CONST.CURRENCY.USD, @@ -1002,8 +1137,9 @@ describe('PerDiem', () => { policy: {...createRandomPolicy(1)}, }, quickAction: undefined, - betas: [CONST.BETAS.ALL], + betas, personalDetails: personalDetailsList, + policyTags, formatPhoneNumber, delegateAccountID: undefined, isTrackIntentUser: false, diff --git a/tests/actions/IOUTest/CreateExpenseByTypeTest.ts b/tests/actions/IOUTest/CreateExpenseByTypeTest.ts index db6167fe67d5..27d800526e02 100644 --- a/tests/actions/IOUTest/CreateExpenseByTypeTest.ts +++ b/tests/actions/IOUTest/CreateExpenseByTypeTest.ts @@ -31,6 +31,7 @@ jest.mock('@libs/actions/IOU/Split', () => ({ jest.mock('@libs/actions/IOU/PerDiem', () => ({ submitPerDiemExpense: jest.fn(), + getPerDiemExpensePolicyID: jest.fn(), })); jest.mock('@src/libs/Navigation/Navigation', () => ({