diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 223e94e0bdde..09176ceefc8f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2298,7 +2298,7 @@ function getIcons( if (isChatThread(report)) { const parentReportAction = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.[report.parentReportActionID]; - const actorAccountID = getReportActionActorAccountID(parentReportAction, report); + const actorAccountID = getReportActionActorAccountID(parentReportAction, report, report); const actorDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[actorAccountID ?? -1], '', false); const actorIcon = { id: actorAccountID, @@ -8034,10 +8034,17 @@ function canLeaveChat(report: OnyxEntry, policy: OnyxEntry): boo return (isChatThread(report) && !!getReportNotificationPreference(report)) || isUserCreatedPolicyRoom(report) || isNonAdminOrOwnerOfPolicyExpenseChat(report, policy); } -function getReportActionActorAccountID(reportAction: OnyxInputOrEntry, iouReport: OnyxInputOrEntry | undefined): number | undefined { +function getReportActionActorAccountID( + reportAction: OnyxInputOrEntry, + iouReport: OnyxInputOrEntry | undefined, + report: OnyxInputOrEntry | undefined, +): number | undefined { switch (reportAction?.actionName) { - case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: - return !isEmptyObject(iouReport) ? iouReport.managerID : reportAction?.childManagerAccountID; + case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: { + const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID; + const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID; + return isPolicyExpenseChat(report) ? ownerAccountID : actorAccountID; + } case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: return reportAction?.adminAccountID ?? reportAction?.actorAccountID; @@ -8046,7 +8053,6 @@ function getReportActionActorAccountID(reportAction: OnyxInputOrEntry @@ -271,7 +266,7 @@ function ReportActionItemSingle({