Skip to content

Commit bc230ea

Browse files
authored
Merge pull request #53408 from ikevin127/ikevin127-withReportOrNotFoundFix
FIX: Task delete confirmation Cancel button navigates to parent report
2 parents 359c55b + c0f5173 commit bc230ea

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/pages/ReportDetailsPage.tsx

+6-13
Original file line numberDiff line numberDiff line change
@@ -875,22 +875,15 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
875875

876876
// Where to navigate back to after deleting the transaction and its report.
877877
const navigateToTargetUrl = useCallback(() => {
878-
let urlToNavigateBack: string | undefined;
879-
878+
// If transaction was not deleted (i.e. Cancel was clicked), do nothing
879+
// which only dismiss the delete confirmation modal
880880
if (!isTransactionDeleted.current) {
881-
if (caseID === CASES.DEFAULT) {
882-
urlToNavigateBack = Task.getNavigationUrlOnTaskDelete(report);
883-
if (urlToNavigateBack) {
884-
Report.setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
885-
Navigation.goBack(urlToNavigateBack as Route);
886-
} else {
887-
Navigation.dismissModal();
888-
}
889-
return;
890-
}
891881
return;
892882
}
893883

884+
let urlToNavigateBack: string | undefined;
885+
886+
// Only proceed with navigation logic if transaction was actually deleted
894887
if (!isEmptyObject(requestParentReportAction)) {
895888
const isTrackExpense = ReportActionsUtils.isTrackExpenseAction(requestParentReportAction);
896889
if (isTrackExpense) {
@@ -906,7 +899,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
906899
Report.setDeleteTransactionNavigateBackUrl(urlToNavigateBack);
907900
ReportUtils.navigateBackOnDeleteTransaction(urlToNavigateBack as Route, true);
908901
}
909-
}, [caseID, iouTransactionID, moneyRequestReport?.reportID, report, requestParentReportAction, isSingleTransactionView, isTransactionDeleted]);
902+
}, [iouTransactionID, requestParentReportAction, isSingleTransactionView, isTransactionDeleted, moneyRequestReport?.reportID]);
910903

911904
const mentionReportContextValue = useMemo(() => ({currentReportID: report.reportID, exactlyMatch: true}), [report.reportID]);
912905

0 commit comments

Comments
 (0)