From 819e1d37c183c333fadb5f3aacc0d69277b5f2fb Mon Sep 17 00:00:00 2001 From: Sophie Aminu Date: Fri, 1 Dec 2023 10:28:46 +0900 Subject: [PATCH] Fix inconsistent workspace tooltip --- src/libs/ReportUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 599963b6a9aa..2d24187b381b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -454,10 +454,12 @@ function getPolicyName(report: OnyxEntry | undefined | EmptyObject, retu } const finalPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; + const parentReport = getRootParentReport(report); + // Public rooms send back the policy name with the reportSummary, // since they can also be accessed by people who aren't in the workspace // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const policyName = finalPolicy?.name || report?.policyName || report?.oldPolicyName || noPolicyFound; + const policyName = finalPolicy?.name || report?.policyName || report?.oldPolicyName || parentReport?.oldPolicyName || noPolicyFound; return policyName; } @@ -2161,7 +2163,7 @@ function getParentReport(report: OnyxEntry): OnyxEntry | EmptyOb * Returns the root parentReport if the given report is nested. * Uses recursion to iterate any depth of nested reports. */ -function getRootParentReport(report: OnyxEntry): OnyxEntry | EmptyObject { +function getRootParentReport(report: OnyxEntry | undefined | EmptyObject): OnyxEntry | EmptyObject { if (!report) { return {}; }