Skip to content

Commit

Permalink
Merge pull request #48621 from wildan-m/wildan/fix/44480-fix-undesire…
Browse files Browse the repository at this point in the history
…d-unavailable-workspace

Fix the getPolicyName function for when the report or policies are not ready
  • Loading branch information
mjasikowski committed Sep 11, 2024
2 parents 2145a26 + 06ebc3c commit e9642dc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,10 @@ const unavailableTranslation = Localize.translateLocal('workspace.common.unavail
*/
function getPolicyName(report: OnyxInputOrEntry<Report>, returnEmptyIfNotFound = false, policy?: OnyxInputOrEntry<Policy>): string {
const noPolicyFound = returnEmptyIfNotFound ? '' : unavailableTranslation;
if (isEmptyObject(report)) {
if (isEmptyObject(report) || (isEmptyObject(allPolicies) && !report?.policyName)) {
return noPolicyFound;
}

if ((!allPolicies || Object.keys(allPolicies).length === 0) && !report?.policyName) {
return unavailableTranslation;
}
const finalPolicy = policy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];

const parentReport = getRootParentReport(report);
Expand Down

0 comments on commit e9642dc

Please sign in to comment.