Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/services/organization-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,15 @@ 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()
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) =>
Expand Down