Oh, I entirely agree with the severity and the "they are not supposed to do that"-ness of it. It's far from right.
I'm just saying that there's nothing in the law or constitution that says they can't.
In this case they'd just say something about the government having an overriding interest in financial management, and without direct evidence that funding was pulled as retaliation the claim doesn't pass the threshold for consideration.
The court has used related reasoning to say that removal of books is speech by the government, and so you have no recourse when the government censors information in libraries.
Or "ice needs to be racist to do their job, and that's more important than equal protection under the law".
It's a fucked situation, but it's not new, and it's not illegal.