Surely 40g of sugar if you do not need all that energy is worse than 0g of sugar.
Almost every advancement in dietary knowledge I have see over my life has indicated more and more that excess sugar (and carbs in general) is by far the biggest problem all over the world. And it is trivial to consume excess carbs with a modern lifestyle in a developed country.
https://jamanetwork.com/journals/jamainternalmedicine/fullar...