Working remotely may negatively impact mental health in the long run—but only in people with particular living situations.