In the UK, by law employers must check that the people they hire have a legal "right to work", i.e. are citizens or foreigners with the relevant visa. In England, landlords must check that prospective tenants have a legal "right to rent", i.e. are lawful residents. Penalties are hefty fines and up to jail.
Hence "flunking the law".