The judge behind the ruling said that the conditions imposed by DHS were "arbitrary and capricious" and "not reasonably related to the purposes"