@@ -12197,21 +12197,36 @@ function saveSplitTransactions(draftTransaction: OnyxEntry<OnyxTypes.Transaction
1219712197
1219812198 API . write ( WRITE_COMMANDS . SPLIT_TRANSACTION , parameters , { optimisticData, successData, failureData} ) ;
1219912199 InteractionManager . runAfterInteractions ( ( ) => removeDraftSplitTransaction ( originalTransactionID ) ) ;
12200+
1220012201 const isSearchPageTopmostFullScreenRoute = isSearchTopmostFullScreenRoute ( ) ;
12202+ const transactionThreadReportID = iouActions . at ( 0 ) ?. childReportID ;
12203+ const transactionThreadReportScreen = Navigation . getReportRouteByID ( transactionThreadReportID ) ;
12204+
1220112205 if ( isSearchPageTopmostFullScreenRoute || ! transactionReport ?. parentReportID ) {
1220212206 Navigation . dismissModal ( ) ;
12207+
12208+ // After the modal is dismissed, remove the transaction thread report screen
12209+ // to avoid navigating back to a report removed by the split transaction.
12210+ requestAnimationFrame ( ( ) => {
12211+ if ( ! transactionThreadReportScreen ?. key ) {
12212+ return ;
12213+ }
12214+
12215+ Navigation . removeScreenByKey ( transactionThreadReportScreen . key ) ;
12216+ } ) ;
12217+
1220312218 return ;
1220412219 }
1220512220 Navigation . dismissModalWithReport ( { reportID : expenseReport ?. reportID ?? String ( CONST . DEFAULT_NUMBER_ID ) } ) ;
1220612221
12207- const transactionThreadReportID = iouActions . at ( 0 ) ?. childReportID ;
12208- const trackTransactionThreadReport = Navigation . getReportRouteByID ( transactionThreadReportID ) ;
12209- InteractionManager . runAfterInteractions ( ( ) => {
12210- if ( ! trackTransactionThreadReport ?. key ) {
12222+ // After the modal is dismissed, remove the transaction thread report screen
12223+ // to avoid navigating back to a report removed by the split transaction.
12224+ requestAnimationFrame ( ( ) => {
12225+ if ( ! transactionThreadReportScreen ?. key ) {
1221112226 return ;
1221212227 }
1221312228
12214- Navigation . removeScreenByKey ( trackTransactionThreadReport . key ) ;
12229+ Navigation . removeScreenByKey ( transactionThreadReportScreen . key ) ;
1221512230 } ) ;
1221612231}
1221712232
0 commit comments