Reagan tried a similar thing and Saturday Night Live did a skit. Been a long time but the joke was, after asking if the respondent was a citizen, there was a follow up question, "If someone were looking for you, where would you hide?"
Point is, the entire Court saw through the charade of reasons offered by the Trump administration given the mass of evidence that the real reasoning was to discriminate. So sure, it gets sent back, and the department can try to make its internal reasoning match what it publicly claims. But the other side will be entitled to discovery, to take depositions, to quiz the decision makers on the real reasons for it. And then that goes back to the lower courts. It does not go back to the Supreme Court.
The process would take several years, at least.
The Court has called the Trump administration a liar on this subject. No way the administration goes back only to be embarrassed again.
Its over.