@@ -35,6 +35,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
3535import Navigation from '@libs/Navigation/Navigation' ;
3636import { getPersonalDetailsForAccountIDs } from '@libs/OptionsListUtils' ;
3737import Parser from '@libs/Parser' ;
38+ import { getReportName } from '@libs/ReportNameUtils' ;
3839import {
3940 canJoinChat ,
4041 canUserPerformWriteAction ,
@@ -45,7 +46,6 @@ import {
4546 getPolicyDescriptionText ,
4647 getPolicyName ,
4748 getReportDescription ,
48- getReportName ,
4949 getReportStatusColorStyle ,
5050 getReportStatusTranslation ,
5151 hasReportNameError ,
@@ -78,6 +78,7 @@ import {callFunctionIfActionIsAllowed} from '@userActions/Session';
7878import CONST from '@src/CONST' ;
7979import ONYXKEYS from '@src/ONYXKEYS' ;
8080import SCREENS from '@src/SCREENS' ;
81+ import reportsSelector from '@src/selectors/Attributes' ;
8182import type { Report , ReportAction } from '@src/types/onyx' ;
8283import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
8384
@@ -106,8 +107,6 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
106107 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
107108 const { isSmallScreenWidth} = useResponsiveLayout ( ) ;
108109 const route = useRoute ( ) ;
109- const invoiceReceiverPolicyID = report ?. invoiceReceiver && 'policyID' in report . invoiceReceiver ? report . invoiceReceiver . policyID : undefined ;
110- const [ invoiceReceiverPolicy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ invoiceReceiverPolicyID } ` ) ;
111110 const [ parentReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getNonEmptyStringOnyxID ( report ?. parentReportID ) ?? getNonEmptyStringOnyxID ( report ?. reportID ) } ` ) ;
112111 const [ grandParentReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getNonEmptyStringOnyxID ( parentReport ?. parentReportID ) } ` ) ;
113112 const [ grandParentReportActions ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ getNonEmptyStringOnyxID ( parentReport ?. parentReportID ) } ` ) ;
@@ -121,6 +120,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
121120 const [ reportNameValuePairs ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report ?. reportID } ` ) ;
122121 const [ reportMetadata ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_METADATA } ${ report ?. reportID } ` ) ;
123122 const isReportArchived = isArchivedReport ( reportNameValuePairs ) ;
123+ const [ reportAttributes ] = useOnyx ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES , { selector : reportsSelector } ) ;
124124
125125 const { translate, localeCompare, formatPhoneNumber} = useLocalize ( ) ;
126126 const theme = useTheme ( ) ;
@@ -129,6 +129,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
129129 const isGroupChat = isGroupChatReportUtils ( report ) || isDeprecatedGroupDM ( report , isReportArchived ) ;
130130 const [ introSelected ] = useOnyx ( ONYXKEYS . NVP_INTRO_SELECTED ) ;
131131 const [ onboarding ] = useOnyx ( ONYXKEYS . NVP_ONBOARDING ) ;
132+ const [ reports ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT ) ;
132133 const allParticipants = getParticipantsAccountIDsForDisplay ( report , false , true , undefined , reportMetadata ) ;
133134 const shouldAddEllipsis = allParticipants ?. length > CONST . DISPLAY_PARTICIPANTS_LIMIT ;
134135 const participants = allParticipants . slice ( 0 , CONST . DISPLAY_PARTICIPANTS_LIMIT ) ;
@@ -149,8 +150,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
149150 const isReportHeaderDataArchived = useReportIsArchived ( reportHeaderData ?. reportID ) ;
150151 const { accountID : currentUserAccountID } = useCurrentUserPersonalDetails ( ) ;
151152 // Use sorted display names for the title for group chats on native small screen widths
152- // eslint-disable-next-line @typescript-eslint/no-deprecated
153- const title = getReportName ( reportHeaderData , policy , parentReportAction , personalDetails , invoiceReceiverPolicy , undefined , undefined , isReportHeaderDataArchived ) ;
153+ const title = getReportName ( reportHeaderData , reportAttributes , reports , parentReportAction ) ;
154154 const subtitle = getChatRoomSubtitle ( reportHeaderData , false , isReportHeaderDataArchived ) ;
155155 // This is used to get the status badge for invoice report subtitle.
156156 const statusTextForInvoiceReport = isParentInvoiceAndIsChatThread
0 commit comments