The UK’s highest court says the plan leaves people at risk of being sent back to unsafe countries.