File the suit it after you have applied for I-485 and EAD via your wife's sponsorship. Yes, they can cancel your H1B at any time. They can get in trouble if the court finds that they did it in retaliation to your lawsuit, but they can still do it. Once you've filed a marriage-based I-485 , you no longer depend on your employer to maintain your legal status.