When can you challenge a subject-matter jurisdiction?
Subject-matter jurisdiction is the requirement that the court have power to hear the specific kind of claim that is brought to that court.(Cornell Law)
Subject-matter jurisdiction may be challenged pre-hearing if a party has some reason to believe the subject matter falls outside the court's subject-matter jurisdiction.
The court may challenge and reject a case for falling outside its subject-matter jurisdiction: "the court may dismiss the case sua sponte—or, on its own—for lack of subject-matter jurisdiction."
A party may challenge a decision after a hearing if it has some reason to believe the case and judgement fell outside a court's subject-matter jurisdiction.