Your question is User-to-Group Mapping for Notifications. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
When a monday notification targets several groups, a user may belong to multiple targeted groups or appear in duplicate mapping records. Implement a function that returns every eligible user exactly once, preserving the order of their first appearance in the mappings.
Exclude the user who triggered the notification, even if that user belongs to a targeted group.
Implement notification_recipients(mappings, target_groups, sender_id).
mappings is a list of two-element lists, where each pair is [user_id, group_id].target_groups is a list of group IDs receiving the notification.sender_id is the user who triggered the notification.mappings.def notification_recipients(mappings, target_groups, sender_id):