Trump may be on firm legal ground. That wont stop the Democrats shopping for a judge who will issue an injunction.
You are correct; all the more reason for Trump to shop a judge, establish the courts jurisdiction and maybe even obtain the rule BEFORE he issues the decree.
Perhaps that is what he is working on .... remember how he suggested after the last 9th court circus that he would work to prevent such judicial shopping in the future?