"Legal" consists entirely of the opinions of lawyers, who are literally trained in law school to see both sides of every problem and construct a defense either way. I suspect the DoJ would have no problem constructing a brief that it's legal.
Ultimately the decision rests entirely with more lawyers on the court, and if they happen to be predisposed, there is no higher power to tell them otherwise. Even a flagrant, direct contradiction of the text is completely irrelevant.
I'm not a lawyer so I don't know how that applies in this case. I just have little doubt that it already has been.