Anyone know exactly how this function works?
No, but based on watching AI behavior and reading the wave coding in MeleeAI.galaxy I suspect that it comes up true if an enemy unit is within sight of a town. I believe this is what's happening when the current version of Starcrack chases your scout all over the place, or when an assault wave gets recalled for base defense.