I'm not going to respond to all the things that others have (correctly) refuted, but I do want to add that after six years working remotely for a variety of companies, I view team communication as the "X factor", the make-or-break mechanism.
I've had jobs wherein I've never felt more alone, even while working out of shared workspaces so I could get my "social" fix, because it was impossible to get hold of my coworkers when I needed them and there were no real processes or protocols in place to facilitate collaboration.
But I've also spent more than two years working for a company that got everything right, during which time I felt more connected to my teammates, both personally and professionally, than I have in any of my in-office gigs.
Daily syncs with the team and weekly syncs with the department, constantly tweaking and optimizing task management and review processes, frequent impromptu video calls that could last anywhere between a minute and hours, coworkers respectful of my personal needs (and tolerant of my then five year-old often "participating" in my calls) and setting time to "have lunch" together at least once a week, literally just eating and talking on a video call with whoever was "around", all came together to make it so it felt like we were all working in a shared space even though most of us weren't on the same continent.
Everything comes down to intention and team dynamics. A good manager will do what they need to to make sure that their subordinates have the tools and attitude required to work together towards the common goal. "Being in the office" is just as much a tool as "working remotely" is, you can use either of those tools well, or poorly.