Due to Android policies changes, since Android 8.1, you may need to turn on the location service to determine the active Wi-Fi name (SSID).
Google's argument is that the Wi-Fi names can be used to determine your location.
This is why you need to have the location permission, and location services need to be active (usually by enabling "location" in the Android quick settings).