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
10 changes: 6 additions & 4 deletions src/libs/actions/MergeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import Onyx from 'react-native-onyx';

import type {UpdateMoneyRequestData, UpdateMoneyRequestDataKeys} from './IOU/UpdateMoneyRequest';

import {getPolicyTagsData} from './IOU';
import {getCleanUpTransactionThreadReportOnyxData} from './IOU/DeleteMoneyRequest';
import {getDeleteTrackExpenseInformation} from './IOU/TrackExpense';
import {getUpdateMoneyRequestParams, getUpdateTrackExpenseParams} from './IOU/UpdateMoneyRequest';
Expand Down Expand Up @@ -228,6 +227,7 @@ function getOnyxTargetTransactionData({
currentUserEmailParam,
isASAPSubmitBetaEnabled,
delegateAccountID,
reportPolicyTags,
isTrackIntentUser,
}: {
targetTransaction: Transaction;
Expand All @@ -243,6 +243,7 @@ function getOnyxTargetTransactionData({
currentUserEmailParam: string;
isASAPSubmitBetaEnabled: boolean;
delegateAccountID: number | undefined;
reportPolicyTags: OnyxEntry<PolicyTagLists>;
isTrackIntentUser: boolean | undefined;
}) {
let data: UpdateMoneyRequestData<UpdateMoneyRequestDataKeys>;
Expand Down Expand Up @@ -283,8 +284,7 @@ function getOnyxTargetTransactionData({
transactionChanges: filteredTransactionChanges,
policy,
policyTagList: policyTags,
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
reportPolicyTags: getPolicyTagsData(targetTransactionThreadParentReport?.policyID),
reportPolicyTags,
policyCategories,
violations: targetTransactionViolations ?? [],
shouldBuildOptimisticModifiedExpenseReportAction,
Expand Down Expand Up @@ -347,6 +347,7 @@ type MergeTransactionRequestParams = {
isASAPSubmitBetaEnabled: boolean;
delegateAccountID: number | undefined;
selfDMReport: OnyxEntry<Report>;
reportPolicyTags: OnyxEntry<PolicyTagLists>;
isTrackIntentUser: boolean | undefined;
};
/**
Expand Down Expand Up @@ -375,6 +376,7 @@ function mergeTransactionRequest({
isASAPSubmitBetaEnabled,
delegateAccountID,
selfDMReport,
reportPolicyTags,
isTrackIntentUser,
}: MergeTransactionRequestParams) {
// For both unreported expenses and expense reports, negate the display amount when storing
Expand Down Expand Up @@ -410,7 +412,6 @@ function mergeTransactionRequest({
receiptID: mergeTransaction.receipt?.receiptID,
reportID: mergeTransaction.reportID,
};

const onyxTargetTransactionData = getOnyxTargetTransactionData({
targetTransaction,
targetTransactionViolations: allTransactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + targetTransaction.transactionID] ?? [],
Expand All @@ -425,6 +426,7 @@ function mergeTransactionRequest({
currentUserEmailParam,
isASAPSubmitBetaEnabled,
delegateAccountID,
reportPolicyTags,
isTrackIntentUser,
});

Expand Down
3 changes: 3 additions & 0 deletions src/pages/TransactionMerge/ConfirmationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function ConfirmationPage({route}: ConfirmationPageProps) {
const [targetTransactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${targetTransactionThreadReportID}`);
const [targetTransactionThreadParentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetTransactionThreadReport?.parentReportID)}`);
const [targetTransactionThreadParentReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${getNonEmptyStringOnyxID(targetTransactionThreadReport?.parentReportID)}`);
const [reportPolicyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(targetTransactionThreadParentReport?.policyID)}`);
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});

const selfDMReport = useSelfDMReport();
Expand All @@ -80,6 +81,7 @@ function ConfirmationPage({route}: ConfirmationPageProps) {
const reportID = mergeTransaction.reportID === CONST.REPORT.UNREPORTED_REPORT_ID ? (findSelfDMReportID() ?? CONST.REPORT.UNREPORTED_REPORT_ID) : mergeTransaction.reportID;

setIsMergingExpenses(true);

mergeTransactionRequest({
mergeTransactionID: transactionID,
mergeTransaction,
Expand All @@ -98,6 +100,7 @@ function ConfirmationPage({route}: ConfirmationPageProps) {
delegateAccountID,
isTrackIntentUser,
selfDMReport,
reportPolicyTags,
});

const reportIDToDismiss = reportID !== CONST.REPORT.UNREPORTED_REPORT_ID ? reportID : undefined;
Expand Down
9 changes: 9 additions & 0 deletions tests/actions/MergeTransactionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function runCrossReportMergeToSourceReportRequest(fixtures: CrossReportMergeToSo
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, mockViolations, mockViolations),
targetTransactionThreadReport: {reportID: targetReport.reportID},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
currentUserAccountIDParam: 123,
currentUserEmailParam: 'existing@example.com',
Expand Down Expand Up @@ -307,6 +308,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target-report-456'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, targetViolations, sourceViolations),
policy: undefined,
Expand Down Expand Up @@ -423,6 +425,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: targetReportID},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID),
policy: undefined,
Expand Down Expand Up @@ -524,6 +527,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: targetExpenseReport.reportID},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, targetViolations, sourceViolations),
policy: undefined,
Expand Down Expand Up @@ -687,6 +691,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target-report-456'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, mockViolations, mockViolations),
policy: undefined,
Expand Down Expand Up @@ -791,6 +796,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target123'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, mockViolations, mockViolations),
policy: undefined,
Expand Down Expand Up @@ -1020,6 +1026,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target-report-456'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, targetViolations, sourceViolations),
policy: undefined,
Expand Down Expand Up @@ -1220,6 +1227,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target-report-456'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, targetViolations, sourceViolations),
policy: undefined,
Expand Down Expand Up @@ -1371,6 +1379,7 @@ describe('mergeTransactionRequest', () => {
sourceTransaction,
targetTransactionThreadReport: {reportID: 'target-report-456'},
targetTransactionThreadParentReport: undefined,
reportPolicyTags: undefined,
targetTransactionThreadParentReportNextStep: undefined,
allTransactionViolations: createAllTransactionViolations(targetTransaction.transactionID, sourceTransaction.transactionID, targetViolations, sourceViolations),
policy: undefined,
Expand Down
Loading