Skip to content

Commit

Permalink
Fix inconsistent workspace tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
chie2727 committed Dec 1, 2023
1 parent f72f629 commit 819e1d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,12 @@ function getPolicyName(report: OnyxEntry<Report> | undefined | EmptyObject, retu
}
const finalPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];

const parentReport = getRootParentReport(report);

Check failure on line 457 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / lint

'getRootParentReport' was used before it was defined

// 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;
}
Expand Down Expand Up @@ -2161,7 +2163,7 @@ function getParentReport(report: OnyxEntry<Report>): OnyxEntry<Report> | EmptyOb
* Returns the root parentReport if the given report is nested.
* Uses recursion to iterate any depth of nested reports.
*/
function getRootParentReport(report: OnyxEntry<Report>): OnyxEntry<Report> | EmptyObject {
function getRootParentReport(report: OnyxEntry<Report> | undefined | EmptyObject): OnyxEntry<Report> | EmptyObject {
if (!report) {
return {};
}
Expand Down

0 comments on commit 819e1d3

Please sign in to comment.