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

[Expense ReportPreview Avatar] Update report preview avatar to use owner #50424

Merged
merged 2 commits into from
Oct 16, 2024
Merged
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
26 changes: 16 additions & 10 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,19 @@ function ReportActionItemSingle({
let actorHint = (login || (displayName ?? '')).replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '');
const isTripRoom = ReportUtils.isTripRoom(report);
const isReportPreviewAction = action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW;
const displayAllActors = isReportPreviewAction && !isTripRoom;
const displayAllActors = isReportPreviewAction && !isTripRoom && !ReportUtils.isPolicyExpenseChat(report);
const isInvoiceReport = ReportUtils.isInvoiceReport(iouReport ?? null);
const isWorkspaceActor = isInvoiceReport || (ReportUtils.isPolicyExpenseChat(report) && (!actorAccountID || displayAllActors));
const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID;
let avatarSource = avatar;
let avatarId: number | string | undefined = actorAccountID;

if (isReportPreviewAction && ReportUtils.isPolicyExpenseChat(report)) {
avatarId = ownerAccountID;
avatarSource = personalDetails[ownerAccountID ?? -1]?.avatar;
displayName = ReportUtils.getDisplayNameForParticipant(ownerAccountID);
actorHint = displayName;
}
if (isWorkspaceActor) {
displayName = ReportUtils.getPolicyName(report, undefined, policy);
actorHint = displayName;
Expand Down Expand Up @@ -193,6 +199,15 @@ function ReportActionItemSingle({
);

const getAvatar = () => {
if (shouldShowSubscriptAvatar) {
return (
<SubscriptAvatar
mainAvatar={icon}
secondaryAvatar={secondaryAvatar}
noMargin
/>
);
}
if (displayAllActors) {
return (
<MultipleAvatars
Expand All @@ -203,15 +218,6 @@ function ReportActionItemSingle({
/>
);
}
if (shouldShowSubscriptAvatar) {
return (
<SubscriptAvatar
mainAvatar={icon}
secondaryAvatar={secondaryAvatar}
noMargin
/>
);
}
return (
<UserDetailsTooltip
accountID={Number(actorAccountID ?? -1)}
Expand Down
Loading