Looks like the issue is that the UniFi server can’t be installed with a version of MongoDB newer then 3.6.0
Fix the issue by installing an older version of MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | sudo apt-key add - echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list sudo apt-get update
Then install MongoDB with
apt install mongodb-org-server
You may run into issues if you already have a version of Mongo installed. Uninstall it and then rerun the above install command.