@@ -4,8 +4,6 @@ import type {ColorValue, TextStyle} from 'react-native';
44import type { OnyxEntry } from 'react-native-onyx' ;
55import type { ValueOf } from 'type-fest' ;
66import useOnyx from '@hooks/useOnyx' ;
7- import type { ReportAvatarDetails } from '@hooks/useReportAvatarDetails' ;
8- import useReportIsArchived from '@hooks/useReportIsArchived' ;
97import useStyleUtils from '@hooks/useStyleUtils' ;
108import useTheme from '@hooks/useTheme' ;
119import useThemeStyles from '@hooks/useThemeStyles' ;
@@ -15,7 +13,6 @@ import type {DisplayNameWithTooltips} from '@libs/ReportUtils';
1513import {
1614 getChatRoomSubtitle ,
1715 getDisplayNamesWithTooltips ,
18- getIcons ,
1916 getParentNavigationSubtitle ,
2017 getReportName ,
2118 isChatThread ,
@@ -26,32 +23,24 @@ import {
2623 isMoneyRequestReport ,
2724 isTrackExpenseReport ,
2825 navigateToDetailsPage ,
29- shouldReportShowSubscript ,
3026} from '@libs/ReportUtils' ;
3127import CONST from '@src/CONST' ;
3228import ONYXKEYS from '@src/ONYXKEYS' ;
3329import ROUTES from '@src/ROUTES' ;
34- import type { Policy , Report } from '@src/types/onyx' ;
35- import type { Icon } from '@src/types/onyx/OnyxCommon' ;
30+ import type { Report } from '@src/types/onyx' ;
3631import { getButtonRole } from './Button/utils' ;
3732import DisplayNames from './DisplayNames' ;
3833import type DisplayNamesProps from './DisplayNames/types' ;
39- import { FallbackAvatar } from './Icon/Expensicons' ;
40- import MultipleAvatars from './MultipleAvatars' ;
4134import ParentNavigationSubtitle from './ParentNavigationSubtitle' ;
4235import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback' ;
43- import SingleReportAvatar from './ReportActionItem/SingleReportAvatar ' ;
36+ import ReportActionAvatars from './ReportActionAvatars ' ;
4437import type { TransactionListItemType } from './SelectionList/types' ;
45- import SubscriptAvatar from './SubscriptAvatar' ;
4638import Text from './Text' ;
4739
4840type AvatarWithDisplayNameProps = {
4941 /** The report currently being looked at */
5042 report : OnyxEntry < Report > ;
5143
52- /** The policy which the user has access to and which the report is tied to */
53- policy ?: OnyxEntry < Policy > ;
54-
5544 /** The size of the avatar */
5645 size ?: ValueOf < typeof CONST . AVATAR_SIZE > ;
5746
@@ -75,16 +64,6 @@ type AvatarWithDisplayNameProps = {
7564
7665 /** Color of the secondary avatar border, usually should match the container background */
7766 avatarBorderColor ?: ColorValue ;
78-
79- /** If we want to override the default avatar behavior and set a single avatar, we should pass this prop. */
80- singleAvatarDetails ?: ReportAvatarDetails ;
81- } ;
82-
83- const fallbackIcon : Icon = {
84- source : FallbackAvatar ,
85- type : CONST . ICON_TYPE_AVATAR ,
86- name : '' ,
87- id : - 1 ,
8867} ;
8968
9069function getCustomDisplayName (
@@ -164,15 +143,13 @@ function getCustomDisplayName(
164143}
165144
166145function AvatarWithDisplayName ( {
167- policy,
168146 report,
169147 isAnonymous = false ,
170148 size = CONST . AVATAR_SIZE . DEFAULT ,
171149 shouldEnableDetailPageNavigation = false ,
172150 shouldEnableAvatarNavigation = true ,
173151 shouldUseCustomSearchTitleName = false ,
174152 transactions = [ ] ,
175- singleAvatarDetails,
176153 openParentReportInCurrentTab = false ,
177154 avatarBorderColor : avatarBorderColorProp ,
178155} : AvatarWithDisplayNameProps ) {
@@ -190,13 +167,10 @@ function AvatarWithDisplayName({
190167 const parentReportActionParam = report ?. parentReportActionID ? parentReportActions ?. [ report . parentReportActionID ] : undefined ;
191168 const title = getReportName ( report , undefined , parentReportActionParam , personalDetails , invoiceReceiverPolicy , reportAttributes ) ;
192169 const subtitle = getChatRoomSubtitle ( report , { isCreateExpenseFlow : true } ) ;
193- const parentNavigationSubtitleData = getParentNavigationSubtitle ( report , policy ) ;
170+ const parentNavigationSubtitleData = getParentNavigationSubtitle ( report ) ;
194171 const isMoneyRequestOrReport = isMoneyRequestReport ( report ) || isMoneyRequest ( report ) || isTrackExpenseReport ( report ) || isInvoiceReport ( report ) ;
195- const isReportArchived = useReportIsArchived ( report ?. reportID ) ;
196- const icons = getIcons ( report , personalDetails , null , '' , - 1 , policy , invoiceReceiverPolicy , isReportArchived ) ;
197172 const ownerPersonalDetails = getPersonalDetailsForAccountIDs ( report ?. ownerAccountID ? [ report . ownerAccountID ] : [ ] , personalDetails ) ;
198173 const displayNamesWithTooltips = getDisplayNamesWithTooltips ( Object . values ( ownerPersonalDetails ) , false ) ;
199- const shouldShowSubscriptAvatar = shouldReportShowSubscript ( report , isReportArchived ) ;
200174 const avatarBorderColor = avatarBorderColorProp ?? ( isAnonymous ? theme . highlightBG : theme . componentBG ) ;
201175
202176 const actorAccountID = useRef < number | null > ( null ) ;
@@ -245,65 +219,34 @@ function AvatarWithDisplayName({
245219
246220 const shouldUseFullTitle = isMoneyRequestOrReport || isAnonymous ;
247221
248- const getAvatar = useCallback ( ( ) => {
249- if ( shouldShowSubscriptAvatar ) {
250- return (
251- < SubscriptAvatar
252- backgroundColor = { avatarBorderColor }
253- mainAvatar = { icons . at ( 0 ) ?? fallbackIcon }
254- secondaryAvatar = { icons . at ( 1 ) }
255- size = { size }
256- />
257- ) ;
258- }
259-
260- if ( ! singleAvatarDetails || singleAvatarDetails . shouldDisplayAllActors || ! singleAvatarDetails . reportPreviewSenderID ) {
261- return (
262- < MultipleAvatars
263- icons = { icons }
264- size = { size }
265- secondAvatarStyle = { [ StyleUtils . getBackgroundAndBorderStyle ( avatarBorderColor ) ] }
266- />
267- ) ;
268- }
269-
270- return (
271- < SingleReportAvatar
272- reportPreviewDetails = { singleAvatarDetails }
273- personalDetails = { personalDetails }
274- containerStyles = { [ styles . actionAvatar , styles . mr3 ] }
275- actorAccountID = { singleAvatarDetails . reportPreviewSenderID }
276- />
277- ) ;
278- } , [ StyleUtils , avatarBorderColor , icons , personalDetails , shouldShowSubscriptAvatar , singleAvatarDetails , size , styles ] ) ;
279-
280- const getWrappedAvatar = useCallback ( ( ) => {
281- const avatar = getAvatar ( ) ;
282-
283- if ( ! shouldEnableAvatarNavigation ) {
284- return < View accessibilityLabel = { title } > { avatar } </ View > ;
285- }
286-
287- return (
288- < View accessibilityLabel = { title } >
289- < PressableWithoutFeedback
290- onPress = { showActorDetails }
291- accessibilityLabel = { title }
292- role = { getButtonRole ( true ) }
293- >
294- { avatar }
295- </ PressableWithoutFeedback >
296- </ View >
297- ) ;
298- } , [ getAvatar , shouldEnableAvatarNavigation , showActorDetails , title ] ) ;
299-
300- const WrappedAvatar = getWrappedAvatar ( ) ;
222+ const multipleAvatars = (
223+ < ReportActionAvatars
224+ singleAvatarContainerStyle = { [ styles . actionAvatar , styles . mr3 ] }
225+ subscriptAvatarBorderColor = { avatarBorderColor }
226+ size = { size }
227+ secondaryAvatarContainerStyle = { StyleUtils . getBackgroundAndBorderStyle ( avatarBorderColor ) }
228+ reportID = { report ?. reportID }
229+ />
230+ ) ;
301231
302232 const headerView = (
303233 < View style = { [ styles . appContentHeaderTitle , styles . flex1 ] } >
304234 { ! ! report && ! ! title && (
305235 < View style = { [ styles . flex1 , styles . flexRow , styles . alignItemsCenter , styles . justifyContentBetween ] } >
306- { WrappedAvatar }
236+ < View accessibilityLabel = { title } >
237+ { shouldEnableAvatarNavigation ? (
238+ < PressableWithoutFeedback
239+ onPress = { showActorDetails }
240+ accessibilityLabel = { title }
241+ role = { getButtonRole ( true ) }
242+ >
243+ { multipleAvatars }
244+ </ PressableWithoutFeedback >
245+ ) : (
246+ multipleAvatars
247+ ) }
248+ </ View >
249+
307250 < View style = { [ styles . flex1 , styles . flexColumn ] } >
308251 { getCustomDisplayName (
309252 shouldUseCustomSearchTitleName ,
0 commit comments