Skip to content
Merged
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
16 changes: 9 additions & 7 deletions src/pages/TransactionDuplicate/Confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import useTransactionThreadReportIDs from '@hooks/useTransactionThreadReportIDs'
import {mergeDuplicates, resolveDuplicates} from '@libs/actions/IOU/Duplicate';
import {setDeleteTransactionNavigateBackUrl} from '@libs/actions/Report';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {TransactionDuplicateNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -104,22 +105,23 @@ function Confirmation() {
const handleMergeDuplicates = useCallback(() => {
const transactionThreadReportID = childReportID ?? generateReportID();
const mergeParams = !childReportID ? {...transactionsMergeParams, transactionThreadReportID} : transactionsMergeParams;
// Server deletes the discarded transaction's now-empty expense report on merge and
// pushes back a "Report not found" payload for it. Hint the guard and redirect to
// the kept transaction's report so the user doesn't land on the discarded one.
// Suppress the NotFound guard for the discarded thread the server tears down on merge.
const keptReportRoute = ROUTES.REPORT_WITH_ID.getRoute(mergeParams.reportID);
setDeleteTransactionNavigateBackUrl(keptReportRoute);
mergeDuplicates({...mergeParams, ...taxData, currentUserAccountID, currentUserLogin: currentUserLogin ?? ''});
if (isSuperWideRHPDisplayed) {
Navigation.dismissToSuperWideRHP();
return;
}
const topmostReportID = Navigation.getTopmostReportId?.();
if (topmostReportID === mergeParams.reportID) {
// From Search, dismiss back to the results (backTo is always set here, so it can't detect Search).
if (isSearchTopmostFullScreenRoute()) {
Navigation.dismissModal();
} else {
Navigation.goBack(keptReportRoute);
return;
}
// From the discarded thread: pop the modal entries, then replace the dead thread with the kept report.
Navigation.dismissModal({
afterTransition: () => Navigation.navigate(keptReportRoute, {forceReplace: true}),
});
}, [childReportID, transactionsMergeParams, taxData, currentUserAccountID, currentUserLogin, isSuperWideRHPDisplayed]);

const handleResolveDuplicates = useCallback(() => {
Expand Down
Loading