I think there are “happy” endings and then there are satisfying endings. I’m especially aware of the latter, because when one is writing mysteries, your readers let you know if they don’t feel you have answered all the questions.
I would say happy endings are when you come to the end of the book, close it, and feel that there is hope in the world. Which doesn’t mean everything has turned out the way you wanted it to at the end of the book. I think an ending should both give a sense of closure–that this story is done, and a sense of the world of the book continuing, that life goes on for these characters.
One thing I’m aware of in writing the end of a book is what is the last image I want to leave the reader with–what is my parting gift to them.