I realized social media was stealing focus from my work by nagging me night and day to re-engage with it. I cut myself off from all but the most simplistic, dark-pattern-free platforms- like HN. My working memory has been freed of clutter and my mood has improved considerably. I recommend sandboxing "tailored for you," dark-patterned online services, or ditching them entirely. (By "sandboxing" I mean accessing them from dedicated platforms off of your mainstream devices.)
Acknowledge that social media is a distraction and understand how it impacts your productivity is vital. For a long time I wasn't able to understand that I have an issue with that.