Question: Suppose a "valid" priest is in "mortal" sin (i.e. he's been out all night at the casino, drunk and just buggered someone an hour ago). He's in a hurry and it's time for him to say mass. He loads up the chalice with the correct wafers. So ... now he's on the altar and he says the right words. Does any of this negate his power to offer a "valid" sacrifice? In other words, does God have the liberty to say "NO WAY"?
The state of the soul of the priest has no bearing on the validity of the sacrament. Much like Paul warns the Corinthians to make sure they take Communion worthily, lest they eat and drink a condemnation upon themselves, the priest is so much more in danger of condemning himself by such a scenario you describe.
But, that does not affect the validity of the sacrament. It is objectively what it is.
SD