I'll disagree slightly, though clearly you are correct that if your goal is to offset calories, then eating a donut negates the benefits of the exercise activity.
My disagreement is that I think exercise should not primarily be about calories - it should be about fitness. And almost all of the fitness gains from exercise persist even if you replace the calories with a donut.
Exercising for 30min and then relacing those spent calories with donuts is FAR better than not exercising and forgoing those extra calories.
Exactly - and on top of that being super extra lean (for vanity purposes) is often actually detrimental to real world performance anyways. There's a balance to everything.
Of course this assumes that in addition to the single donut the rest of your diet is decent - if you're eating shit all day then you are asking for an injury