The bug
Bees appear to claim hives or nests even if they cannot find a valid path to them. In my testing, the bees in one cage try to get to a nest from another cage, even though there's an empty nest just nearby.
This is closely related to, but not the same issue as MC-159418.
To reproduce
Build multiple cages
Place nests in the cages
Summon bees in the cages
→ ❌ Sometimes bees will pick a nest that they cannot pathfind to (you can check that with/data get entity <bee> HivePos
)
Maybe bees can find flowers behind walls as well? Haven't tested that yet though.