From c72510ae97a7008774121206e69a287a7e241494 Mon Sep 17 00:00:00 2001 From: Nevil Mathew Date: Tue, 28 Oct 2025 13:34:11 +0530 Subject: [PATCH 1/2] refactor(organization): optimize feature access logic for role mappings --- src/services/organization-feature.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/services/organization-feature.js b/src/services/organization-feature.js index 505ecdee6..712e5ead3 100644 --- a/src/services/organization-feature.js +++ b/src/services/organization-feature.js @@ -334,17 +334,13 @@ module.exports = class organizationFeatureHelper { // For each role, determine accessible features // If role has mappings in current org, use those; otherwise use default org mappings const accessibleFeatureCodes = new Set() - roleTitles.forEach((role) => { - const currentOrgFeatures = currentOrgRoleFeatureMap.get(role) - if (currentOrgFeatures?.size > 0) { - // Current org has explicit mappings for this role - use only those - currentOrgFeatures.forEach((feature) => accessibleFeatureCodes.add(feature)) - } else { - // No current org mappings for this role - fall back to default org - const defaultOrgFeatures = defaultOrgRoleFeatureMap.get(role) - defaultOrgFeatures?.forEach((feature) => accessibleFeatureCodes.add(feature)) - } - }) + + for (const role of roleTitles) { + const defSet = defaultOrgRoleFeatureMap.get(role) + const curSet = currentOrgRoleFeatureMap.get(role) + defSet?.forEach((code) => accessibleFeatureCodes.add(code)) + curSet?.forEach((code) => accessibleFeatureCodes.add(code)) + } // Filter to only accessible features organizationFeatures = organizationFeatures.filter((feature) => From 3150b66e07f15e6eb7b78f8271217c16babc73b0 Mon Sep 17 00:00:00 2001 From: Nevil Mathew Date: Tue, 28 Oct 2025 15:26:00 +0530 Subject: [PATCH 2/2] refactor(organization): clarify comment on feature access logic for role mappings --- src/services/organization-feature.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/organization-feature.js b/src/services/organization-feature.js index 712e5ead3..2f6e1f5bb 100644 --- a/src/services/organization-feature.js +++ b/src/services/organization-feature.js @@ -332,7 +332,7 @@ module.exports = class organizationFeatureHelper { }) // For each role, determine accessible features - // If role has mappings in current org, use those; otherwise use default org mappings + // Union features from both default org and current org role mappings const accessibleFeatureCodes = new Set() for (const role of roleTitles) {