@@ -150,24 +150,40 @@ function ReportActionItemSingle({
150
150
} else {
151
151
secondaryAvatar = { name : '' , source : '' , type : 'avatar' } ;
152
152
}
153
- const icon = {
154
- source : avatarSource ?? FallbackAvatar ,
155
- type : isWorkspaceActor ? CONST . ICON_TYPE_WORKSPACE : CONST . ICON_TYPE_AVATAR ,
156
- name : primaryDisplayName ?? '' ,
157
- id : avatarId ,
158
- } ;
153
+ const icon = useMemo (
154
+ ( ) => ( {
155
+ source : avatarSource ?? FallbackAvatar ,
156
+ type : isWorkspaceActor ? CONST . ICON_TYPE_WORKSPACE : CONST . ICON_TYPE_AVATAR ,
157
+ name : primaryDisplayName ?? '' ,
158
+ id : avatarId ,
159
+ } ) ,
160
+ [ avatarSource , isWorkspaceActor , primaryDisplayName , avatarId ] ,
161
+ ) ;
159
162
160
163
// Since the display name for a report action message is delivered with the report history as an array of fragments
161
164
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually,
162
165
// we should stop referring to the report history items entirely for this information.
163
- const personArray = displayName
164
- ? [
165
- {
166
- type : 'TEXT' ,
167
- text : displayName ,
168
- } ,
169
- ]
170
- : action ?. person ;
166
+ const personArray = useMemo ( ( ) => {
167
+ const baseArray = displayName
168
+ ? [
169
+ {
170
+ type : 'TEXT' ,
171
+ text : displayName ,
172
+ } ,
173
+ ]
174
+ : [ action ?. person ?. at ( 0 ) ] ?? [ ] ;
175
+
176
+ if ( displayAllActors && secondaryAvatar ?. name ) {
177
+ return [
178
+ ...baseArray ,
179
+ {
180
+ type : 'TEXT' ,
181
+ text : secondaryAvatar ?. name ?? '' ,
182
+ } ,
183
+ ] ;
184
+ }
185
+ return baseArray ;
186
+ } , [ displayName , action ?. person , displayAllActors , secondaryAvatar ?. name ] ) ;
171
187
172
188
const reportID = report ?. reportID ;
173
189
const iouReportID = iouReport ?. reportID ;
@@ -231,6 +247,74 @@ function ReportActionItemSingle({
231
247
</ UserDetailsTooltip >
232
248
) ;
233
249
} ;
250
+
251
+ const getHeading = useCallback ( ( ) => {
252
+ return ( ) => {
253
+ if ( displayAllActors && personArray . length === 2 && isReportPreviewAction ) {
254
+ return (
255
+ < View style = { [ styles . flexRow ] } >
256
+ < ReportActionItemFragment
257
+ style = { [ styles . flex1 ] }
258
+ key = { `person-${ action ?. reportActionID } -${ 0 } ` }
259
+ accountID = { actorAccountID ?? - 1 }
260
+ fragment = { { ...personArray . at ( 0 ) , type : 'TEXT' , text : displayName ?? '' } }
261
+ delegateAccountID = { action ?. delegateAccountID }
262
+ isSingleLine
263
+ actorIcon = { icon }
264
+ moderationDecision = { getReportActionMessage ( action ) ?. moderationDecision ?. decision }
265
+ />
266
+ < Text
267
+ numberOfLines = { 1 }
268
+ style = { [ styles . chatItemMessageHeaderSender , styles . pre ] }
269
+ >
270
+ { ` & ` }
271
+ </ Text >
272
+ < ReportActionItemFragment
273
+ style = { [ styles . flex1 ] }
274
+ key = { `person-${ action ?. reportActionID } -${ 1 } ` }
275
+ accountID = { parseInt ( `${ secondaryAvatar ?. id ?? - 1 } ` , 10 ) }
276
+ fragment = { { ...personArray . at ( 1 ) , type : 'TEXT' , text : secondaryAvatar . name ?? '' } }
277
+ delegateAccountID = { action ?. delegateAccountID }
278
+ isSingleLine
279
+ actorIcon = { secondaryAvatar }
280
+ moderationDecision = { getReportActionMessage ( action ) ?. moderationDecision ?. decision }
281
+ />
282
+ </ View >
283
+ ) ;
284
+ }
285
+ return (
286
+ < View >
287
+ { personArray . map ( ( fragment , index ) => (
288
+ < ReportActionItemFragment
289
+ style = { [ styles . flex1 ] }
290
+ // eslint-disable-next-line react/no-array-index-key
291
+ key = { `person-${ action ?. reportActionID } -${ index } ` }
292
+ accountID = { actorAccountID ?? - 1 }
293
+ fragment = { { ...fragment , type : fragment ?. type ?? '' , text : fragment ?. text ?? '' } }
294
+ delegateAccountID = { action ?. delegateAccountID }
295
+ isSingleLine
296
+ actorIcon = { icon }
297
+ moderationDecision = { getReportActionMessage ( action ) ?. moderationDecision ?. decision }
298
+ />
299
+ ) ) }
300
+ </ View >
301
+ ) ;
302
+ } ;
303
+ } , [
304
+ displayAllActors ,
305
+ secondaryAvatar ,
306
+ isReportPreviewAction ,
307
+ personArray ,
308
+ styles . flexRow ,
309
+ styles . flex1 ,
310
+ styles . chatItemMessageHeaderSender ,
311
+ styles . pre ,
312
+ action ,
313
+ actorAccountID ,
314
+ displayName ,
315
+ icon ,
316
+ ] ) ;
317
+
234
318
const hasEmojiStatus = ! displayAllActors && status ?. emojiCode ;
235
319
const formattedDate = DateUtils . getStatusUntilDate ( status ?. clearAfter ?? '' ) ;
236
320
const statusText = status ?. text ?? '' ;
@@ -261,18 +345,7 @@ function ReportActionItemSingle({
261
345
accessibilityLabel = { actorHint }
262
346
role = { CONST . ROLE . BUTTON }
263
347
>
264
- { personArray ?. map ( ( fragment , index ) => (
265
- < ReportActionItemFragment
266
- // eslint-disable-next-line react/no-array-index-key
267
- key = { `person-${ action ?. reportActionID } -${ index } ` }
268
- accountID = { actorAccountID ?? - 1 }
269
- fragment = { { ...fragment , type : fragment . type ?? '' , text : fragment . text ?? '' } }
270
- delegateAccountID = { action ?. delegateAccountID }
271
- isSingleLine
272
- actorIcon = { icon }
273
- moderationDecision = { getReportActionMessage ( action ) ?. moderationDecision ?. decision }
274
- />
275
- ) ) }
348
+ { getHeading ( ) }
276
349
</ PressableWithoutFeedback >
277
350
{ ! ! hasEmojiStatus && (
278
351
< Tooltip text = { statusTooltipText } >
0 commit comments