Skip to content

use working group instead of group for in/exclusions#3118

Open
bcb37 wants to merge 1 commit into
devfrom
feature/use-working-group-for-inclusion-exclusion-logic
Open

use working group instead of group for in/exclusions#3118
bcb37 wants to merge 1 commit into
devfrom
feature/use-working-group-for-inclusion-exclusion-logic

Conversation

@bcb37
Copy link
Copy Markdown
Collaborator

@bcb37 bcb37 commented May 14, 2026

For inclusion/exclusion logic, consider only a user's working group to determine whether to include or exclude them from experiments and feature flags.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates inclusion/exclusion matching so experiment and feature flag eligibility uses a user's workingGroup rather than all group memberships.

Changes:

  • Replaces group membership expansion with working group mapping in ExperimentAssignmentService.
  • Updates/adds unit tests for experiment-level exclusion behavior when workingGroup differs from group.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/backend/src/api/services/ExperimentAssignmentService.ts Changes group matching input for inclusion/exclusion logic to workingGroup.
packages/backend/test/unit/services/ExperimentAssignmentService.test.ts Updates exclusion test data and adds a negative working-group exclusion case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2226 to 2230
if (experimentUser.workingGroup) {
Object.keys(experimentUser.workingGroup).forEach((type) => {
userGroups.push({ type, groupId: experimentUser.workingGroup[type] });
});
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that we need to worry about groupsForSession, but experimentUser.group and experimentUser.workingGroup are not the same type.

Comment on lines +571 to +578
it('[experimentLevelExclusionInclusion] should not return an exclusion reason if a user workingGroup is not on exclusion list', async () => {
const userDoc = {
id: 'user2',
group: { teacher: ['teacher1', 'teacher2'] },
workingGroup: { teacher: 'teacher2' },
};
const exp = structuredClone(simpleIndividualAssignmentExperiment);
const [includedExperiment, exclusionReason] = await testedModule.experimentLevelExclusionInclusion([exp], userDoc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants