You're exactly right. It depends on what you trade off in order to flatten your boat. When heeling, if you want to flatten, you have to change ... something. You need to reduce sail, sheet out, move weight, change directions, or some combination. Some of these choices are win-win. For example, if you are in high winds having no trouble approaching hull speed, the choice to reduce sail can be a win-win. It can flatten the boat out just enough to pick up a bit of speed to reach hull speed, and also be at a more comfortable position. Or, it might be that you need to point higher, so you find that you can pinch to keep the boat flat while still making better progress toward your destination. Again, that's a win-win.Maybe that goes without saying, but sometimes I get the feeling that the "flatter is faster" argument gets abused by simplicity.
But, sometimes reducing sail area or turning to a different point of sail, just to flatten the boat out, may not improve your VMG. It might even decrease your water speed.
And, indeed, some hulls actually sail better with a slight heel.
If flatter was always faster, then you would never see world-class monohull racers heeled. And, of course, that is not the case.