I do think there are times when I'm less productivity working from home compared to the office. I also think as a team we're less creative. Some of the best stuff I've done in my career has come out of casual conversations with my team about the stuff we're building. I've noticed I don't think about what I'm building as much when working remote, I'm just building it.
That said, I don't think 100% office is good either. That tends to just burn me out and I know other people I work with say the same thing. I think I'm at my best when it's 2-3 days in the office and the rest working from home.
40 hours in the office is really extreme these days. And any potential benefit of having employees working together in an office 24/7 is going to be negated by their dissatisfaction. Were I working at Twitter I'd probably be looking for a new job after this announcement. Not so much for the remote work decision either, but just the general lack of respect for how the employees prefer to work. This lack of flexibility probably means Musk won't just stop at remote work but he'll want keep track of your productivity, when you arriving in the morning, how long you take for lunch, etc. Working for these kinds of people in my experience is a living hell.