As a practical example let's say you take a date to your local trendy sushi place. You both get gold-leafed deep fried Wagyu fatback tuna rolls and some Yuzu duck fat-washed 50-year-old whiskey highballs. The final bill is $100 (I'll use round-ish numbers for this example). The bartender comps you 30% because you all are cool and discuss your shared experience bartending or jetskiing or whatever. Ordinarily your tip would have been 20% for a total of $120. In this case your bill is now $70 plus your newly selected gratuity. Take the difference between the original bill with tip and your current bill without tip and divide it in two. This is the floor for your new tip, in this case (120-70)/2 = $25. This is indeed something like a 35% gratuity but they hooked you up and made that custom drink for your charming new beau. As a matter of fact you should round up from this number because they have side work to do and you make pretty decent money as a software engineer/LLM tickler/product sorcerer. Just make it $30 for a nice round hundo.
If you're friends with the manager and they comp your dinner to do you a solid and impress your date then you should tip 50% of what the bill would have been minimum. This is why you should keep cash in your pocket - shake the waiter's hand on your way out and palm it to them. If that's not possible then go to use the restroom and talk to them on your way back so they can run your card through the POS on a blank check to give them said tip.
This is how you do things with class. This is what I wish somebody had explained to me when I was 20 and kinda broke (i.e. eager to save money that I would have spent anyway) before I embarrassed myself by failing to do such. If you are similarly unaware then now you know too :-)
As an addendum this also applies to coffee and pizza places but the numbers become coarser. Buying them the equivalent of a beer at your local dive ($3ish) is customary.