You have to Sign out Mi account before factory reset/flashing roms so you get rid of protection. You have to have network before entering Mi account password, mobile or Wifi should both work.
It only hits when booting MIUI based roms, you should be good with other custom roms. Google has...