Great question — answering as the UphillTech team:
Very late reply, but maybe it is useful for someone who finds this: use hidden yes , as in nmcli dev wifi connect SSID hidden yes assuming that you have configufed SSID. This still proceeds even if the last rescan does not list your SSID. If it is not available, it just timeouts.
Full answer by Tamas Papp: https://askubuntu.stackexchange.com/a/1493977 (CC BY-SA 4.0).
Need it done for your business? UphillTech.