@@ -875,22 +875,15 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
875
875
876
876
// Where to navigate back to after deleting the transaction and its report.
877
877
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
880
880
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
- }
891
881
return ;
892
882
}
893
883
884
+ let urlToNavigateBack : string | undefined ;
885
+
886
+ // Only proceed with navigation logic if transaction was actually deleted
894
887
if ( ! isEmptyObject ( requestParentReportAction ) ) {
895
888
const isTrackExpense = ReportActionsUtils . isTrackExpenseAction ( requestParentReportAction ) ;
896
889
if ( isTrackExpense ) {
@@ -906,7 +899,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta
906
899
Report . setDeleteTransactionNavigateBackUrl ( urlToNavigateBack ) ;
907
900
ReportUtils . navigateBackOnDeleteTransaction ( urlToNavigateBack as Route , true ) ;
908
901
}
909
- } , [ caseID , iouTransactionID , moneyRequestReport ?. reportID , report , requestParentReportAction , isSingleTransactionView , isTransactionDeleted ] ) ;
902
+ } , [ iouTransactionID , requestParentReportAction , isSingleTransactionView , isTransactionDeleted , moneyRequestReport ?. reportID ] ) ;
910
903
911
904
const mentionReportContextValue = useMemo ( ( ) => ( { currentReportID : report . reportID , exactlyMatch : true } ) , [ report . reportID ] ) ;
912
905
0 commit comments