I should have been sentenced to prison , but my lawyer convinced the court that I'm innocent
The person who said the sentence is thankful because he is not in prison now , he does not wish to be in prison .
My question is: could we use "should have +pp" to mean that something was to expected but it didn't happen (and we are happy because it didn't happen) ?