Skip to content

Commit 156e211

Browse files
committed
fix: simplify getXeroTenants to use optional chaining
Replace verbose nullish guards with optional chaining as the behavior is identical — all intermediate properties are objects, so falsy checks and optional chaining handle the same undefined/null cases.
1 parent 7ea9865 commit 156e211

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/libs/PolicyUtils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,10 +1299,7 @@ function hasIndependentTags(policy: OnyxEntry<Policy>, policyTagList: OnyxEntry<
12991299

13001300
/** Get the Xero organizations connected to the policy */
13011301
function getXeroTenants(policy: Policy | undefined): Tenant[] {
1302-
if (!policy || !policy.connections || !policy.connections.xero || !policy.connections.xero.data) {
1303-
return [];
1304-
}
1305-
return policy.connections.xero.data.tenants ?? [];
1302+
return policy?.connections?.xero?.data?.tenants ?? [];
13061303
}
13071304

13081305
function findCurrentXeroOrganization(tenants: Tenant[] | undefined, organizationID: string | undefined): Tenant | undefined {

0 commit comments

Comments
 (0)