From 18af1707fef79564010cec28b185059c8bf30d4d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 15 Jul 2024 17:13:34 +0700 Subject: [PATCH] fix: User avatar and email does not show when using Submit --- src/libs/ReportUtils.ts | 30 ++++++++++++++++++++++-------- src/pages/home/HeaderView.tsx | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f7dca71fd15f..ed26a9f83b35 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1827,7 +1827,7 @@ function getWorkspaceIcon(report: OnyxInputOrEntry, policy?: OnyxInputOr * Gets the personal details for a login by looking in the ONYXKEYS.PERSONAL_DETAILS_LIST Onyx key (stored in the local variable, allPersonalDetails). If it doesn't exist in Onyx, * then a default object is constructed. */ -function getPersonalDetailsForAccountID(accountID: number): Partial { +function getPersonalDetailsForAccountID(accountID: number, personalDetailsData?: Partial): Partial { if (!accountID) { return {}; } @@ -1836,19 +1836,28 @@ function getPersonalDetailsForAccountID(accountID: number): Partial, +): string { if (!accountID) { return ''; } - - const personalDetails = getPersonalDetailsForAccountID(accountID); + const personalDetails = getPersonalDetailsForAccountID(accountID, personalDetailsData); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const formattedLogin = LocalePhoneNumber.formatPhoneNumber(personalDetails.login || ''); // This is to check if account is an invite/optimistically created one @@ -3343,7 +3352,12 @@ function getInvoicesChatName(report: OnyxEntry): string { /** * Get the title for a report. */ -function getReportName(report: OnyxEntry, policy?: OnyxEntry, parentReportActionParam?: OnyxInputOrEntry): string { +function getReportName( + report: OnyxEntry, + policy?: OnyxEntry, + parentReportActionParam?: OnyxInputOrEntry, + personalDetails?: Partial, +): string { let formattedName: string | undefined; const parentReportAction = parentReportActionParam ?? ReportActionsUtils.getParentReportAction(report); if (isChatThread(report)) { @@ -3421,7 +3435,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa } if (isSelfDM(report)) { - formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true); + formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true, personalDetails); } if (isInvoiceRoom(report)) { @@ -3441,7 +3455,7 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa } }); const isMultipleParticipantReport = participantsWithoutCurrentUser.length > 1; - return participantsWithoutCurrentUser.map((accountID) => getDisplayNameForParticipant(accountID, isMultipleParticipantReport)).join(', '); + return participantsWithoutCurrentUser.map((accountID) => getDisplayNameForParticipant(accountID, isMultipleParticipantReport, true, false, personalDetails)).join(', '); } /** diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 7077c1a325c5..9005f2bb7c0e 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -82,7 +82,7 @@ function HeaderView({report, personalDetails, parentReport, parentReportAction, const isTaskReport = ReportUtils.isTaskReport(report); const reportHeaderData = !isTaskReport && !isChatThread && report.parentReportID ? parentReport : report; // Use sorted display names for the title for group chats on native small screen widths - const title = ReportUtils.getReportName(reportHeaderData, undefined, parentReportAction); + const title = ReportUtils.getReportName(reportHeaderData, undefined, parentReportAction, personalDetails); const subtitle = ReportUtils.getChatRoomSubtitle(reportHeaderData); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(reportHeaderData); const reportDescription = ReportUtils.getReportDescriptionText(report);