a slightly shorter way if you feel its not too confusing:

system_group_ids =  activation_keys.map(&:system_group_ids).flatten.compact.uniq