From 7f3a5021c1bf8556f0f1a741fd22f9b36862a1e5 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Sun, 14 Sep 2025 23:43:23 +0800 Subject: [PATCH] fix: vacation delegate bugs --- .../ReportActionAvatars/useReportActionAvatars.ts | 10 +++++----- src/libs/ReportUtils.ts | 4 ++++ src/pages/home/ReportScreen.tsx | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionAvatars/useReportActionAvatars.ts b/src/components/ReportActionAvatars/useReportActionAvatars.ts index 045763556672..701deb7ae89d 100644 --- a/src/components/ReportActionAvatars/useReportActionAvatars.ts +++ b/src/components/ReportActionAvatars/useReportActionAvatars.ts @@ -87,7 +87,7 @@ function useReportActionAvatars({ const reportPolicyID = iouReport?.policyID ?? chatReport?.policyID; const chatReportPolicyIDExists = chatReport?.policyID === CONST.POLICY.ID_FAKE || !chatReport?.policyID; const changedPolicyID = actionChildReport?.policyID ?? iouReport?.policyID; - const shouldUseChangedPolicyID = !!changedPolicyID && changedPolicyID !== (chatReport?.policyID ?? iouReport?.policyID); + const shouldUseChangedPolicyID = !!changedPolicyID && changedPolicyID !== (reportPolicyID ?? iouReport?.policyID); const retrievedPolicyID = chatReportPolicyIDExists ? reportPolicyID : chatReport?.policyID; const policyID = shouldUseChangedPolicyID ? changedPolicyID : (passedPolicyID ?? retrievedPolicyID); @@ -154,7 +154,7 @@ function useReportActionAvatars({ const isWorkspacePolicy = !!policy && policy.type !== CONST.POLICY.TYPE.PERSONAL; const isATripRoom = isTripRoom(chatReport); - const isWorkspaceWithoutChatReportProp = !chatReport && isWorkspacePolicy; + const isWorkspaceWithoutChatReportProp = !chatReport?.reportID && isWorkspacePolicy; const isAWorkspaceChat = isPolicyExpenseChat(chatReport) || isWorkspaceWithoutChatReportProp; const isATripPreview = action?.actionName === CONST.REPORT.ACTIONS.TYPE.TRIP_PREVIEW; const isReportPreviewOrNoAction = !action || isAReportPreviewAction; @@ -199,8 +199,8 @@ function useReportActionAvatars({ const invoiceReport = [iouReport, chatReport, reportChatReport].find((susReport) => isInvoiceReport(susReport) || susReport?.chatType === CONST.REPORT.TYPE.INVOICE); const isNestedInInvoiceReport = !!invoiceReport; const isWorkspaceActor = isAInvoiceReport || (isAWorkspaceChat && (!actorAccountID || displayAllActors)); - const isChatReportOnlyProp = !iouReport && chatReport; - const isWorkspaceChatWithoutChatReport = !chatReport && isAWorkspaceChat; + const isChatReportOnlyProp = !iouReport && chatReport?.reportID; + const isWorkspaceChatWithoutChatReport = !chatReport?.reportID && isAWorkspaceChat; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const usePersonalDetailsAvatars = (isChatReportOnlyProp || isWorkspaceChatWithoutChatReport) && isReportPreviewOrNoAction && !isATripPreview; const useNearestReportAvatars = (!accountID || !action) && accountIDs.length === 0; @@ -208,7 +208,7 @@ function useReportActionAvatars({ const getIconsWithDefaults = (onyxReport: OnyxInputOrEntry) => getIcons(onyxReport, personalDetails, avatar ?? fallbackIcon ?? FallbackAvatar, defaultDisplayName, accountID, policy, invoiceReceiverPolicy); - const reportIcons = getIconsWithDefaults(chatReport ?? iouReport); + const reportIcons = getIconsWithDefaults(chatReport?.reportID ? chatReport : iouReport); const delegateAvatar: IconType | undefined = delegatePersonalDetails ? { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c0a0c0c26c78..0a0c13631a3e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5567,6 +5567,10 @@ function getPendingChatMembers(accountIDs: number[], previousPendingChatMembers: */ function getParentNavigationSubtitle(report: OnyxEntry, isParentReportArchived = false): ParentNavigationSummaryParams { const parentReport = getParentReport(report); + if (report?.hasParentAccess === false) { + return {}; + } + if (isEmptyObject(parentReport)) { const ownerAccountID = report?.ownerAccountID; const personalDetails = ownerAccountID ? allPersonalDetails?.[ownerAccountID] : undefined; diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 57bf14a4de3f..95675b0f8b04 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -224,6 +224,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { const report = useMemo( () => reportOnyx && { + hasParentAccess: reportOnyx.hasParentAccess, lastReadTime: reportOnyx.lastReadTime, reportID: reportOnyx.reportID, policyID: reportOnyx.policyID,