@@ -162,14 +162,42 @@ function TransactionPreviewContent({
162162 const shouldShowIOUHeader = ! ! from && ! ! to ;
163163
164164 // If available, retrieve the split share from the splits object of the transaction, if not, display an even share.
165- const splitShare = useMemo (
166- ( ) =>
167- shouldShowSplitShare
168- ? ( transaction ?. comment ?. splits ?. find ( ( split ) => split . accountID === sessionAccountID ) ?. amount ??
169- calculateAmount ( isReportAPolicyExpenseChat ? 1 : participantAccountIDs . length - 1 , amount ?? 0 , requestCurrency ?? '' , action ?. actorAccountID === sessionAccountID ) )
170- : 0 ,
171- [ shouldShowSplitShare , isReportAPolicyExpenseChat , action ?. actorAccountID , participantAccountIDs . length , transaction ?. comment ?. splits , amount , requestCurrency , sessionAccountID ] ,
172- ) ;
165+ const actorAccountID = action ?. actorAccountID ;
166+ const splitShare = useMemo ( ( ) => {
167+ if ( ! shouldShowSplitShare ) {
168+ return 0 ;
169+ }
170+
171+ const splitAmount = transaction ?. comment ?. splits ?. find ( ( split ) => split . accountID === sessionAccountID ) ?. amount ;
172+ if ( splitAmount !== undefined ) {
173+ return splitAmount ;
174+ }
175+
176+ let originalParticipantCount = participantAccountIDs . length ;
177+
178+ if ( isBillSplit ) {
179+ // Try to get the participant count from transaction splits data
180+ const transactionSplitsCount = transaction ?. comment ?. splits ?. length ;
181+ if ( transactionSplitsCount && transactionSplitsCount > 0 ) {
182+ originalParticipantCount = transactionSplitsCount ;
183+ } else if ( isMoneyRequestAction ( action ) ) {
184+ originalParticipantCount = getOriginalMessage ( action ) ?. participantAccountIDs ?. length ?? participantAccountIDs . length ;
185+ }
186+ }
187+
188+ return calculateAmount ( isReportAPolicyExpenseChat ? 1 : originalParticipantCount - 1 , amount ?? 0 , requestCurrency ?? '' , actorAccountID === sessionAccountID ) ;
189+ } , [
190+ shouldShowSplitShare ,
191+ isReportAPolicyExpenseChat ,
192+ participantAccountIDs . length ,
193+ transaction ?. comment ?. splits ,
194+ amount ,
195+ requestCurrency ,
196+ sessionAccountID ,
197+ isBillSplit ,
198+ action ,
199+ actorAccountID ,
200+ ] ) ;
173201
174202 const shouldWrapDisplayAmount = ! ( isBillSplit || shouldShowMerchantOrDescription || isTransactionScanning ) ;
175203 const previewTextViewGap = ( shouldShowCategoryOrTag || ! shouldWrapDisplayAmount ) && styles . gap2 ;
0 commit comments