Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: User avatar and email does not show when using Submit #45393

Merged
merged 5 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, 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<PersonalDetails> {
function getPersonalDetailsForAccountID(accountID: number, personalDetailsData?: Partial<PersonalDetailsList>): Partial<PersonalDetails> {
if (!accountID) {
return {};
}
Expand All @@ -1918,7 +1918,11 @@ function getPersonalDetailsForAccountID(accountID: number): Partial<PersonalDeta
isOptimisticPersonalDetail: true,
};

return allPersonalDetails?.[accountID] ?? defaultDetails;
if (!personalDetailsData) {
return allPersonalDetails?.[accountID] ?? defaultDetails;
}

return personalDetailsData?.[accountID] ?? defaultDetails;
}

/**
Expand All @@ -1935,12 +1939,18 @@ const phoneNumberCache: Record<string, string> = {};
/**
* Get the displayName for a single report participant.
*/
function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = false, shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string {
function getDisplayNameForParticipant(
accountID?: number,
shouldUseShortForm = false,
shouldFallbackToHidden = true,
shouldAddCurrentUserPostfix = false,
personalDetailsData?: Partial<PersonalDetailsList>,
): string {
if (!accountID) {
return '';
}

const personalDetails = getPersonalDetailsOrDefault(allPersonalDetails?.[accountID]);
const personalDetails = getPersonalDetailsOrDefault(personalDetailsData?.[accountID] ?? allPersonalDetails?.[accountID]);
if (!personalDetails) {
return '';
}
Expand Down Expand Up @@ -3461,7 +3471,12 @@ function getInvoicesChatName(report: OnyxEntry<Report>): string {
/**
* Get the title for a report.
*/
function getReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, parentReportActionParam?: OnyxInputOrEntry<ReportAction>): string {
function getReportName(
report: OnyxEntry<Report>,
policy?: OnyxEntry<Policy>,
parentReportActionParam?: OnyxInputOrEntry<ReportAction>,
personalDetails?: Partial<PersonalDetailsList>,
): string {
let formattedName: string | undefined;
const parentReportAction = parentReportActionParam ?? ReportActionsUtils.getParentReportAction(report);
const parentReportActionMessage = ReportActionsUtils.getReportActionMessage(parentReportAction);
Expand Down Expand Up @@ -3545,7 +3560,7 @@ function getReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, pa
}

if (isSelfDM(report)) {
formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true);
formattedName = getDisplayNameForParticipant(currentUserAccountID, undefined, undefined, true, personalDetails);
}

if (isInvoiceRoom(report)) {
Expand All @@ -3565,7 +3580,7 @@ function getReportName(report: OnyxEntry<Report>, policy?: OnyxEntry<Policy>, 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(', ');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading