Validity isn't the issue here. Clearly, the mass, if that's what it was, is displeasing to Our Lord. It would be better if it were invalid. That way Our Lord wasn't present to be stomped and spat upon.
What should you do? That depends. Did you go with knowledge or positive doubt?
Were you there because of a social or professional decorum such as a co-worker's "confirmation?" Did you leave once you realized it was bad? Or did you go deliberately? Out of idle curiosity? Did you take "communion?" Actively participate after knowing it was bad?
IMO, I'm no moral theologian, but if you knew it was wrong, went out of unnecessary curiosity, actively participated after knowledge, or took communion, make as perfect an Act of Contrition as you're able, and get to Confession ASAP. Call a priest. Don't wait for the scheduled time unless it's today.
If you found yourself in the situation without intention and left at once, still make an Act of Contrition, and get to Confession at the next regular opportunity. (For a sin to be mortal, you must have knowledge the act is seriously evil.)
Either way, make some sort of reparation to Our Lord in case it was valid and also pray for those present, that the Holy Ghost open their eyes.