Nobody likes a sleepless night. I doubt that is a controversial claim, and it rightfully isn't. However, sometimes our minds can have different plans for us when we want to get things done, whether that be resting or working through impending due dates.
The human brain likes to think...a lot.
Unfortunately for us, our minds do not submit to our rules. When something dark or depressing happens in your life, it is only natural to start reflecting on it almost to an unhealthy degree as you try to analyze every specific detail. Strange as it is, the worst things that happen to you become more attractive to think about than happier things.
Despite these persistent thoughts, the situation typically isn't that deep. Everyone has their own reasons for committing the actions that they do, but that doesn't mean there's some elaborate explanation for every little thing that wrecks your world. Sometimes things just happen because they happen. There isn't much to it.
You can't continue to blame yourself for the mistakes others make.
One of the biggest misconceptions we have when we lie awake at night is the idea that we are to blame for all of the ways others treat us. This is true to some degree, as the way you interact with others has an obvious impact on what they think of you. Conversely, believing that every action done to you is directly or indirectly your own fault is simply not a notion you should waste time entertaining.
Nobody is responsible for another's reaction to an action. At that point, someone is trying to own feelings that aren't theirs. That being said, you do still need to be aware of your own actions in order to live life as someone who wants to bring others joy. You might not be responsible for the actions of others, but you ARE responsible for your OWN actions.
Is it true that you made some kind of mistake that you believe caused the other individual(s) involved to act out against you? If that is the case: OWN UP to what you did. Apologize for how it affected them, forgive yourself for what you did wrong, and don't repeat your mistake. Period. It's that simple, and that's the deepest level of thinking that is required here.
Focus on the here and now!
Instead of wasting empty nights of your life analyzing and reanalyzing things that are long settled and irreparable, invest your energy into the things you can do to improve your state of mind. Start training yourself to change the subject in the constantly switching channels of your own mentality.
There will be the occasional relapse when your brain will suddenly jerk back to a moment that in some way connects to those negative emotions. There's no sugarcoating that, and you can't avoid it forever. But what you can do is learn to appreciate why these events went down and understand how it was a good thing for your own growth in the end. Look how far you've come now!
The second you let the demons of your past take that happiness away from you is the moment where you can make a choice: let them consume you all over again, or take the high road and wave goodbye to them from the other side of hell. Are you ready for that journey?