Skip to content
Open
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
14 changes: 11 additions & 3 deletions src/components/ReportActionItem/TransactionPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Navigation from '@libs/Navigation/Navigation';
import {getOriginalMessage, isMoneyRequestAction as isMoneyRequestActionReportActionsUtils} from '@libs/ReportActionsUtils';
import {getTransactionDetails} from '@libs/ReportUtils';
import {getReviewNavigationRoute} from '@libs/TransactionPreviewUtils';
import {getExpenseTypeTranslationKey, getOriginalTransactionWithSplitInfo, getTransactionType, removeSettledAndApprovedTransactions} from '@libs/TransactionUtils';
import {getExpenseTypeTranslationKey, getOriginalTransactionWithSplitInfo, getTransactionID, getTransactionType, removeSettledAndApprovedTransactions} from '@libs/TransactionUtils';
import type {PlatformStackRouteProp} from '@navigation/PlatformStackNavigation/types';
import type {TransactionDuplicateNavigatorParamList} from '@navigation/types';
import {clearWalletTermsError} from '@userActions/PaymentMethods';
Expand Down Expand Up @@ -59,6 +59,13 @@ function TransactionPreview(props: TransactionPreviewProps) {
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`];
const personalDetails = usePersonalDetails();

// Load thread transaction's complete duplicate list for cross-workspace comparison
const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`];
const threadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(route.params?.threadReportID)}`];

const threadViolations = useTransactionViolations(getTransactionID(threadReport));
const [threadDuplicates] = useTransactionsByID(
useMemo(() => threadViolations?.find((v) => v.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [], [threadViolations]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is compiled with react-compiler, we might not need the useMemo here.

);

// Get transaction violations for given transaction id from onyx, find duplicated transactions violations and get duplicates
const allDuplicateIDs = useMemo(() => violations?.find((violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [], [violations]);
const [allDuplicates] = useTransactionsByID(allDuplicateIDs);
Expand All @@ -82,8 +89,9 @@ function TransactionPreview(props: TransactionPreviewProps) {
}, [chatReportID]);

const navigateToReviewFields = useCallback(() => {
Navigation.navigate(getReviewNavigationRoute(Navigation.getActiveRoute(), route.params?.threadReportID, transaction, duplicates, policyCategories, transactionReport));
}, [route.params?.threadReportID, transaction, duplicates, policyCategories, transactionReport]);
const allDuplicateTransactions = [...duplicates, ...(threadDuplicates ?? [])];
Navigation.navigate(getReviewNavigationRoute(Navigation.getActiveRoute(), route.params?.threadReportID, transaction, allDuplicateTransactions, policyCategories, transactionReport));
}, [route.params?.threadReportID, transaction, duplicates, threadDuplicates, policyCategories, transactionReport]);

const transactionPreview = transaction;

Expand Down
4 changes: 2 additions & 2 deletions src/pages/TransactionDuplicate/ReviewTaxCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ function ReviewTaxRate() {
const route = useRoute<PlatformStackRouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.TAX_CODE>>();
const {translate} = useLocalize();
const [reviewDuplicates] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES, {canBeMissing: true});
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reviewDuplicates?.reportID ?? route.params.threadReportID}`, {canBeMissing: true});
const policy = usePolicy(report?.policyID);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, {canBeMissing: true});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, {canBeMissing: true});
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(route.params.threadReportID)}`, {canBeMissing: true});

const transactionID = getTransactionID(report);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`, {canBeMissing: true});
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, {
Expand All @@ -38,6 +37,7 @@ function ReviewTaxRate() {
const [allDuplicates] = useTransactionsByID(allDuplicateIDs);
const [reviewDuplicatesReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(reviewDuplicates?.reportID)}`, {canBeMissing: true});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getNonEmptyStringOnyxID(reviewDuplicatesReport?.policyID)}`, {canBeMissing: true});
const policy = usePolicy(reviewDuplicatesReport?.policyID);

const compareResult = compareDuplicateTransactionFields(transaction, allDuplicates, reviewDuplicatesReport, undefined, policyCategories);
const stepNames = Object.keys(compareResult.change ?? {}).map((key, index) => (index + 1).toString());
Expand Down
Loading