Yes, active sonar will find them but by the time they’re that close it might be too late.
Passive sonar, what I analyzed while on active duty, “listens” for low frequency noise generated by a rotating mass or cylinder firing off the Diesel engine, prop and shaft noises, etc..
While a diesel boat is running on battery, it’s moving slow and makes almost no detectable noise. BLACK HOLE!
Sound travels fast and long, long distances in water. The sooner you detect them, the faster other assets can search, detect, identify and destroy.
We used to catch the commies coming out of Kamchatka or the Norwegian Sea pretty much as soon as they hit deep water!
Clean frequencies were submerged and “dirty noises” were on the surface.
And yes, this is all unclassified!