@@ -1650,8 +1650,8 @@ function getSendInvoiceInformation(
1650
1650
const { amount = 0 , currency = '' , created = '' , merchant = '' , category = '' , tag = '' , taxCode = '' , taxAmount = 0 , billable, comment, participants} = transaction ?? { } ;
1651
1651
const trimmedComment = ( comment ?. comment ?? '' ) . trim ( ) ;
1652
1652
const senderWorkspaceID = participants ?. find ( ( participant ) => participant ?. isSender ) ?. policyID ?? '' ;
1653
- const receiverParticipant = participants ?. find ( ( participant ) => participant ?. accountID ) ;
1654
- const receiverAccountID = receiverParticipant ? .accountID ?? - 1 ;
1653
+ const receiverParticipant = participants ?. find ( ( participant ) => participant ?. accountID ) ?? invoiceChatReport ?. invoiceReceiver ;
1654
+ const receiverAccountID = receiverParticipant && 'accountID' in receiverParticipant && receiverParticipant . accountID ? receiverParticipant . accountID : - 1 ;
1655
1655
let receiver = ReportUtils . getPersonalDetailsForAccountID ( receiverAccountID ) ;
1656
1656
let optimisticPersonalDetailListAction = { } ;
1657
1657
@@ -1704,11 +1704,12 @@ function getSendInvoiceInformation(
1704
1704
// STEP 4: Add optimistic personal details for participant
1705
1705
const shouldCreateOptimisticPersonalDetails = isNewChatReport && ! allPersonalDetails [ receiverAccountID ] ;
1706
1706
if ( shouldCreateOptimisticPersonalDetails ) {
1707
+ const receiverLogin = receiverParticipant && 'login' in receiverParticipant && receiverParticipant . login ? receiverParticipant . login : '' ;
1707
1708
receiver = {
1708
1709
accountID : receiverAccountID ,
1709
1710
avatar : UserUtils . getDefaultAvatarURL ( receiverAccountID ) ,
1710
- displayName : LocalePhoneNumber . formatPhoneNumber ( receiverParticipant ?. login ?? '' ) ,
1711
- login : receiverParticipant ?. login ,
1711
+ displayName : LocalePhoneNumber . formatPhoneNumber ( receiverLogin ) ,
1712
+ login : receiverLogin ,
1712
1713
isOptimisticPersonalDetail : true ,
1713
1714
} ;
1714
1715
@@ -6497,22 +6498,20 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On
6497
6498
6498
6499
if ( ReportUtils . isPolicyExpenseChat ( chatReport ) || shouldAddAsReport ) {
6499
6500
participants = [ { accountID : 0 , reportID : chatReport ?. reportID , isPolicyExpenseChat : ReportUtils . isPolicyExpenseChat ( chatReport ) , selected : true } ] ;
6501
+ } else if ( ReportUtils . isInvoiceRoom ( chatReport ) ) {
6502
+ participants = [
6503
+ { reportID : chatReport ?. reportID , selected : true } ,
6504
+ {
6505
+ policyID : chatReport ?. policyID ,
6506
+ isSender : true ,
6507
+ selected : false ,
6508
+ } ,
6509
+ ] ;
6500
6510
} else {
6501
6511
const chatReportOtherParticipants = Object . keys ( chatReport ?. participants ?? { } )
6502
6512
. map ( Number )
6503
6513
. filter ( ( accountID ) => accountID !== currentUserAccountID ) ;
6504
6514
participants = chatReportOtherParticipants . map ( ( accountID ) => ( { accountID, selected : true } ) ) ;
6505
-
6506
- if ( ReportUtils . isInvoiceRoom ( chatReport ) ) {
6507
- participants = [
6508
- ...participants ,
6509
- {
6510
- policyID : chatReport ?. policyID ,
6511
- isSender : true ,
6512
- selected : false ,
6513
- } ,
6514
- ] ;
6515
- }
6516
6515
}
6517
6516
6518
6517
Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION_DRAFT } ${ transactionID } ` , { participants, participantsAutoAssigned : true } ) ;
0 commit comments