Happiness is not the surplus of pleasant over unpleasant moments. Rather, happiness consists in seeing one’s life in its entirety as meaningful and worthwhile.
As Nietzsche put it, if you have a why to live, you can bear almost any how.
As far as we can tell, from a purely scientific viewpoint, human life has absolutely no meaning. Humans are the outcome of blind evolutionary processes that operate without goal or purpose.
Hence any meaning that people ascribe to their lives is just a delusion.
So perhaps happiness is synchronising one’s personal delusions of meaning with the prevailing collective delusions.