@@ -823,6 +823,23 @@ function changeTransactionsReport(
823823 const oldReportID = isUnreportedExpense ? CONST . REPORT . UNREPORTED_REPORT_ID : transaction . reportID ;
824824 const oldReport = allReports ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ oldReportID } ` ] ;
825825
826+ const isUnreported = reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
827+ const optimisticMoneyRequestReportActionID = rand64 ( ) ;
828+
829+ const originalMessage = getOriginalMessage ( oldIOUAction ) as OriginalMessageIOU ;
830+ const newIOUAction = {
831+ ...oldIOUAction ,
832+ originalMessage : {
833+ ...originalMessage ,
834+ IOUReportID : reportID ,
835+ type : isUnreported ? CONST . IOU . REPORT_ACTION_TYPE . TRACK : CONST . IOU . REPORT_ACTION_TYPE . CREATE ,
836+ } ,
837+ reportActionID : optimisticMoneyRequestReportActionID ,
838+ pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD ,
839+ actionName : oldIOUAction ?. actionName ?? CONST . REPORT . ACTIONS . TYPE . MOVED_TRANSACTION ,
840+ created : oldIOUAction ?. created ?? DateUtils . getDBTime ( ) ,
841+ } ;
842+
826843 // 1. Optimistically change the reportID on the passed transactions
827844 optimisticData . push ( {
828845 onyxMethod : Onyx . METHOD . MERGE ,
@@ -832,6 +849,7 @@ function changeTransactionsReport(
832849 comment : {
833850 hold : null ,
834851 } ,
852+ ...( oldIOUAction ? { linkedTrackedExpenseReportAction : newIOUAction } : { } ) ,
835853 } ,
836854 } ) ;
837855
@@ -940,7 +958,6 @@ function changeTransactionsReport(
940958 const allowNegative = shouldEnableNegative ( newReport ) ;
941959
942960 // 3. Keep track of the new report totals
943- const isUnreported = reportID === CONST . REPORT . UNREPORTED_REPORT_ID ;
944961 const targetReportID = isUnreported ? selfDMReportID : reportID ;
945962 const { amount : transactionAmount = 0 , currency : transactionCurrency } = getTransactionDetails ( transaction , undefined , undefined , allowNegative ) ?? { } ;
946963 const oldReportTotal = oldReport ?. total ?? 0 ;
@@ -974,22 +991,6 @@ function changeTransactionsReport(
974991 }
975992
976993 // 4. Optimistically update the IOU action reportID
977- const optimisticMoneyRequestReportActionID = rand64 ( ) ;
978-
979- const originalMessage = getOriginalMessage ( oldIOUAction ) as OriginalMessageIOU ;
980- const newIOUAction = {
981- ...oldIOUAction ,
982- originalMessage : {
983- ...originalMessage ,
984- IOUReportID : reportID ,
985- type : isUnreported ? CONST . IOU . REPORT_ACTION_TYPE . TRACK : CONST . IOU . REPORT_ACTION_TYPE . CREATE ,
986- } ,
987- reportActionID : optimisticMoneyRequestReportActionID ,
988- pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD ,
989- actionName : oldIOUAction ?. actionName ?? CONST . REPORT . ACTIONS . TYPE . MOVED_TRANSACTION ,
990- created : oldIOUAction ?. created ?? DateUtils . getDBTime ( ) ,
991- } ;
992-
993994 const trackExpenseActionableWhisper = isUnreportedExpense ? getTrackExpenseActionableWhisper ( transaction . transactionID , selfDMReportID ) : undefined ;
994995
995996 if ( oldIOUAction ) {
0 commit comments