This is actually fairly similar to a position that is put forward by Alexander Gerard in An Essay on Taste:
Objects conceived to be in any of these ways incongruous, always gratify the sense of ridicule: but they may excite, at the same time, a more important feeling, which, by occupying the mind, prevents our attending to the incongruity, or extinguishes the sentiment thence resulting, as soon as it begins to rise. Enormous vice, though of all things the most incongruous to the natural system of our minds, is never esteemed ridiculous. Pain or misery is never in itself ridiculous; it can become such only by being accidentally connected with unsuitable circumstances, and by failing to excite pity so intense as may swallow up the ludicrous sensation.
(The 'sense of ridicule' is Gerard's name for what we nowadays would usually call the 'sense of humor'. It is, in his own words, the "sense which perceives, and is gratified by the odd, the ridiculous, the humorous, the witty; and whose gratification often produces, and always tends to, mirth, laughter, and amusement.") Thus Gerard's view is that an object that is incongruous in certain ways will naturally stimulate mirth, laughter, and amusement, but that the object can simultaneously produce a sentiment that impedes this expression, and that one possible case is when the object that is incongruous also elicits strong moral disapproval. Things that inspire strong pity can have a similar effect. Gerard at several points also indicates that the sense of ridicule might in a number of different kinds of cases simply intensify the sentiments of other inner senses, like our sense of imitation (which is more or less our sense of how realistic or unrealistic a representation is).
Beattie has a similar account, although somewhat more complicated because he distinguishes the ludicrous (incites laughter simply) from the ridiculous (incites contemptuous or disapproving laughter). In "On Laughter, and Ludicrous Composition", he says:
It would seem then, that those absurdities in ourselves or others, which provoke the disapprobation of the moral faculty, cannot be ludicrous because in a sound mind they give rise to emotions inconsistent with, and far more powerful than, that whereof laughter is the outward indication.
To a certain point, moral disapproval changes the ludicrous to the ridiculous (as when we have a mocking attitude to a wicked character on the stage), but beyond that point, when the wrong is monstrous, people of sound mind cannot find it humorous because "moral disapprobation is a more powerful emotion than laughter" and when they are inconsistent, the stronger makes the weaker impossible.
One could argue for a slightly different view, though, which is that the sense of humor, itself, is actually a fairly minimal thing -- our ability to recognize the odd or incongruous -- and that what we usually think of as mirth or amusement is actually a complex response. So our sense of whether something is a good joke or not actually depends on how it affects a number of our 'inner senses'. The sense of novelty is a good example here. Novelty is obviously a major component in a lot of humor; some jokes rely heavily on it and even old tried-and-true jokes often need to seem fresh in some way if they are to do more than induce a smile or small chuckle. So some humorous response is not merely the sense of humor, but also tangled up in the surprise or shock arising from our sense of something's novelty. Similar things can be said about the sense of imitation or realism, since really great jokes often have not just oddness and freshness but also that air of 'that's way too true'. And it's not at all implausible to argue that this could also be true of the sense of morals, or sense of virtue, as Gerard calls it -- our response is shifted from mirth and amusement to disapproval by things that are too far out of moral bounds. In an account like this, the expression of the sense of humor would be more or less the same; it's just that the overall emotional response would be different because of the way other 'senses' contribute.