After 21 years of working from home, I started a new job almost 2 years ago that required being in the office almost all of the time, and much to my surprise I mostly love it. While it does have the danger of distractions, for the kind of work I do it's mostly perfect because my users are sat around me. It helps that it's a great location, and that the people I work with are fun and deeply knowledgable.
I never thought I'd say this, but right now, there's no way I'd trade this for working from home again.
So I guess it's a huge "it depends" from me. I can imagine another job that would have a less-than-wonderful office environment but a great technical challenge making me okay with working from home again.