diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5e50f69e28fa..64a082200c2f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1241,8 +1241,7 @@ function isUserCreatedPolicyRoom(report: OnyxEntry): boolean { * Whether the provided report is a Policy Expense chat. */ function isPolicyExpenseChat(option: OnyxInputOrEntry | OptionData | Participant): boolean { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return getChatType(option) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || (option && 'isPolicyExpenseChat' in option && option.isPolicyExpenseChat) || false; + return getChatType(option) === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT || !!(option && 'isPolicyExpenseChat' in option && option.isPolicyExpenseChat); } function isInvoiceRoom(report: OnyxEntry): boolean { @@ -8459,16 +8458,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, - report: OnyxInputOrEntry | undefined, -): number | undefined { +function getReportActionActorAccountID(reportAction: OnyxEntry, iouReport: OnyxEntry, report: OnyxEntry): number | undefined { switch (reportAction?.actionName) { case CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW: { const ownerAccountID = iouReport?.ownerAccountID ?? reportAction?.childOwnerAccountID; const actorAccountID = iouReport?.managerID ?? reportAction?.childManagerAccountID; - return isPolicyExpenseChat(report) ? ownerAccountID : actorAccountID; + + if (isPolicyExpenseChat(report)) { + return ownerAccountID; + } + + return actorAccountID; } case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: @@ -8478,6 +8478,7 @@ function getReportActionActorAccountID( return reportAction?.actorAccountID; } } + function createDraftWorkspaceAndNavigateToConfirmationScreen(transactionID: string, actionName: IOUAction): void { const isCategorizing = actionName === CONST.IOU.ACTION.CATEGORIZE; const {expenseChatReportID, policyID, policyName} = createDraftWorkspace(); diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 068a1f25187f..6ab8c30ab5a1 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -131,6 +131,8 @@ function ReportActionItemSingle({ avatarId = delegatePersonalDetails?.accountID; } else if (isReportPreviewAction && isTripRoom) { displayName = report?.reportName ?? ''; + avatarSource = personalDetails?.[ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.avatar; + avatarId = ownerAccountID; } // If this is a report preview, display names and avatars of both people involved @@ -210,9 +212,9 @@ function ReportActionItemSingle({ Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(iouReportID, Navigation.getReportRHPActiveRoute())); return; } - showUserDetails(action?.delegateAccountID ? action.delegateAccountID : actorAccountID); + showUserDetails(Number(icon.id)); } - }, [isWorkspaceActor, reportID, actorAccountID, action?.delegateAccountID, iouReportID, displayAllActors]); + }, [isWorkspaceActor, reportID, iouReportID, displayAllActors, icon.id]); const shouldDisableDetailPage = useMemo( () =>