How to execute a command when ALL of the players are close enough
If all players are nearby, that means that no players are far away. In command form:
/execute unless entity @a[distance=3..] run <command>
But that still executes if someone is in other dimensions, you can fix that this way:
/execute unless entity @a[distance=3..] in the_nether unless entity @a[distance=0..] in the_end unless entity @a[distance=0..] run <command>
If you want the command to execute in the overworld, you have to add in overworld
before run
.