Skip to content

Commit

Permalink
Match report header to report preview avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
grgia committed Sep 19, 2024
1 parent b77181f commit e81f87e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ function hasOnlyNonReimbursableTransactions(iouReportID: string | undefined): bo
*/
function isOneTransactionReport(reportID: string): boolean {
const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? ([] as ReportAction[]);
return ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions) !== null;
return !!ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions);
}

/*
Expand Down Expand Up @@ -6657,7 +6657,7 @@ function shouldReportShowSubscript(report: OnyxEntry<Report>): boolean {
return true;
}

if (isExpenseReport(report) && isOneTransactionReport(report?.reportID ?? '-1')) {
if (isExpenseReport(report)) {
return true;
}

Expand Down
15 changes: 7 additions & 8 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ function ReportActionItemSingle({
const actorAccountID = ReportUtils.getReportActionActorAccountID(action, iouReport);
const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`);
let displayName = ReportUtils.getDisplayNameForParticipant(actorAccountID);

const icons = ReportUtils.getIcons(iouReport ?? null, personalDetails);
const {avatar, login, pendingFields, status, fallbackIcon} = personalDetails[actorAccountID ?? -1] ?? {};
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
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 && ReportUtils.isIOUReport(iouReport ?? null);
const displayAllActors = isReportPreviewAction && !isTripRoom && ReportUtils.isIOUReport(iouReport ?? null) && icons.length > 1;
const isInvoiceReport = ReportUtils.isInvoiceReport(iouReport ?? null);
const isWorkspaceActor = isInvoiceReport || (ReportUtils.isPolicyExpenseChat(report) && (!actorAccountID || displayAllActors));
const ownerAccountID = iouReport?.ownerAccountID ?? action?.childOwnerAccountID;
Expand Down Expand Up @@ -134,7 +134,6 @@ function ReportActionItemSingle({
const secondaryAccountId = ownerAccountID === actorAccountID || isInvoiceReport ? managerID : ownerAccountID;
const secondaryUserAvatar = personalDetails?.[secondaryAccountId ?? -1]?.avatar ?? FallbackAvatar;
const secondaryDisplayName = ReportUtils.getDisplayNameForParticipant(secondaryAccountId);

secondaryAvatar = {
source: secondaryUserAvatar,
type: CONST.ICON_TYPE_AVATAR,
Expand Down Expand Up @@ -175,7 +174,7 @@ function ReportActionItemSingle({
]
: action?.person ?? [];

if (displayAllActors && secondaryAvatar?.name) {
if (displayAllActors) {
return [
...baseArray,
{
Expand Down Expand Up @@ -215,7 +214,7 @@ function ReportActionItemSingle({
if (displayAllActors) {
return (
<MultipleAvatars
icons={[icon, secondaryAvatar]}
icons={icons}
isInReportAction
shouldShowTooltip
secondAvatarStyle={[StyleUtils.getBackgroundAndBorderStyle(theme.appBG), isHovered ? StyleUtils.getBackgroundAndBorderStyle(theme.hoverComponentBG) : undefined]}
Expand All @@ -225,8 +224,8 @@ function ReportActionItemSingle({
if (shouldShowSubscriptAvatar) {
return (
<SubscriptAvatar
mainAvatar={icon}
secondaryAvatar={secondaryAvatar}
mainAvatar={icons[0]}
secondaryAvatar={icons[1]}
noMargin
/>
);
Expand Down Expand Up @@ -258,11 +257,11 @@ function ReportActionItemSingle({
icon,
styles.actionAvatar,
fallbackIcon,
secondaryAvatar,
StyleUtils,
theme.appBG,
theme.hoverComponentBG,
isHovered,
icons,
]);

const getHeading = useMemo(() => {
Expand Down

0 comments on commit e81f87e

Please sign in to comment.