@@ -1083,10 +1083,36 @@ function updateSplitTransactions({
10831083 expenseReport,
10841084} : UpdateSplitTransactionsParams ) {
10851085 const chatReport = allReportsList ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ expenseReport ?. chatReportID } ` ] ;
1086+ const expenseReportParentChat = getReportOrDraftReport ( chatReport ?. parentReportID ) ;
10861087 const originalTransactionID = transactionData ?. originalTransactionID ?? CONST . IOU . OPTIMISTIC_TRANSACTION_ID ;
10871088 const originalTransaction = allTransactionsList ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ originalTransactionID } ` ] ;
10881089 const originalTransactionDetails = getTransactionDetails ( originalTransaction ) ;
1089- const participants = getMoneyRequestParticipantsFromReport ( expenseReport , currentUserPersonalDetails . accountID ) ;
1090+ const autoParticipants = getMoneyRequestParticipantsFromReport ( expenseReport , currentUserPersonalDetails . accountID ) ;
1091+ // Delegate split edit can reach this flow without the workspace expense chat in Onyx.
1092+ const fallbackPolicyParticipant =
1093+ autoParticipants . length === 0 && ! chatReport && expenseReport ?. chatReportID && expenseReport ?. policyID
1094+ ? {
1095+ accountID : 0 ,
1096+ reportID : expenseReport . chatReportID ,
1097+ isPolicyExpenseChat : true ,
1098+ selected : true ,
1099+ policyID : expenseReport . policyID ,
1100+ }
1101+ : undefined ;
1102+ const participants = fallbackPolicyParticipant ? [ fallbackPolicyParticipant ] : autoParticipants ;
1103+ let fallbackPolicyParentChatReport = expenseReportParentChat ;
1104+ if ( ! fallbackPolicyParentChatReport && chatReport && isPolicyExpenseChatReportUtil ( chatReport ) ) {
1105+ fallbackPolicyParentChatReport = chatReport ;
1106+ }
1107+ if ( ! fallbackPolicyParentChatReport && fallbackPolicyParticipant ) {
1108+ fallbackPolicyParentChatReport = {
1109+ reportID : fallbackPolicyParticipant . reportID ,
1110+ type : CONST . REPORT . TYPE . CHAT ,
1111+ chatType : CONST . REPORT . CHAT_TYPE . POLICY_EXPENSE_CHAT ,
1112+ policyID : fallbackPolicyParticipant . policyID ,
1113+ ownerAccountID : expenseReport ?. ownerAccountID ,
1114+ } as OnyxTypes . Report ;
1115+ }
10901116 const splitExpenses = transactionData ?. splitExpenses ?? [ ] ;
10911117
10921118 // Get all children once (including orphaned), then filter for non-orphaned
@@ -1325,7 +1351,7 @@ function updateSplitTransactions({
13251351 odometerStart : splitExpense . odometerStart ,
13261352 odometerEnd : splitExpense . odometerEnd ,
13271353 } ,
1328- parentChatReport : getReportOrDraftReport ( getReportOrDraftReport ( expenseReport ?. chatReportID ) ?. parentReportID ) ,
1354+ parentChatReport : fallbackPolicyParentChatReport ,
13291355 existingTransaction : originalTransaction ,
13301356 isASAPSubmitBetaEnabled,
13311357 currentUserAccountIDParam : currentUserPersonalDetails ?. accountID ,
0 commit comments