Skip to content

Commit 7291742

Browse files
committed
Fix confirmation page doesn't show details when merge with a card transaction
1 parent d268da4 commit 7291742

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/pages/TransactionMerge/ConfirmationPage.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback, useMemo, useState} from 'react';
1+
import React, {useCallback, useEffect, useMemo, useState} from 'react';
22
import {View} from 'react-native';
33
import type {OnyxEntry} from 'react-native-onyx';
44
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
@@ -19,6 +19,7 @@ import {buildMergedTransactionData, getSourceTransactionFromMergeTransaction, ge
1919
import Navigation from '@libs/Navigation/Navigation';
2020
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
2121
import type {MergeTransactionNavigatorParamList} from '@libs/Navigation/types';
22+
import {openReport} from '@userActions/Report';
2223
import ONYXKEYS from '@src/ONYXKEYS';
2324
import type SCREENS from '@src/SCREENS';
2425
import type {Transaction} from '@src/types/onyx';
@@ -42,9 +43,24 @@ function ConfirmationPage({route}: ConfirmationPageProps) {
4243
canBeMissing: true,
4344
});
4445

45-
const targetTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getTransactionThreadReportID(targetTransaction)}`];
46+
const targetTransactionThreadReportID = getTransactionThreadReportID(targetTransaction);
47+
const targetTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${targetTransactionThreadReportID}`];
4648
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${targetTransactionThreadReport?.policyID}`, {canBeMissing: true});
4749

50+
// When user selects a card transaction to merge, that card transaction becomes the target transaction.
51+
// The App may not have the transaction thread report loaded for card transactions, so we need to trigger
52+
// OpenReport to ensure the transaction thread report is available.
53+
useEffect(() => {
54+
if (!targetTransactionThreadReportID && targetTransaction?.reportID) {
55+
openReport(targetTransaction.reportID);
56+
return;
57+
}
58+
59+
if (targetTransactionThreadReportID && !targetTransactionThreadReport) {
60+
openReport(targetTransactionThreadReportID);
61+
}
62+
}, [targetTransactionThreadReportID, targetTransaction, targetTransactionThreadReport]);
63+
4864
// Build the merged transaction data for display
4965
const mergedTransactionData = useMemo(() => buildMergedTransactionData(targetTransaction, mergeTransaction), [targetTransaction, mergeTransaction]);
5066

@@ -72,7 +88,7 @@ function ConfirmationPage({route}: ConfirmationPageProps) {
7288
Navigation.dismissModal();
7389
}, [targetTransaction, mergeTransaction, sourceTransaction, transactionID]);
7490

75-
if (isLoadingOnyxValue(mergeTransactionMetadata)) {
91+
if (isLoadingOnyxValue(mergeTransactionMetadata) || !targetTransactionThreadReport?.reportID) {
7692
return <FullScreenLoadingIndicator />;
7793
}
7894

0 commit comments

Comments
 (0)