Let’s take out the obvious contrast of happiness in poverty vs non-poverty. When we ask if money can buy you happiness, we’re really asking about whether spending disposable income on things that you don’t need to survive would make you happier. And as someone who went from lower-class to upper-class, I can safely say that money can buy you happiness.
The thing is that people are just spending it on things that only give them temporary happiness. And when what they bought stops bringing them happiness, they claim that money can’t buy happiness. But when spent a different way, it can buy you happiness. For example, if you love dogs, you could buy a puppy. Or if you have some kind of curable disability like poor vision, you can get surgery to fix it. Or if your friend has a heart disease and need surgery to fix it, you could pay for it and save her life. Or maybe your mother suffers from a mental illness and the way to help her mental well-being is to take care of her financially and put her in a better environment, then helping her would bring you happiness.