Once you're in the
aggregate() command it only focuses on the layer you're aggregating, so you can't reference the atlas layer field normally with just double quotes (it thinks that's on the aggregated layer).
To tell it you are talking about a field in the atlas layer, try referring to the atlas layer specifically using
attribute(). Note that the field is referred to with single quotes and is case-sensitive