Upper Tribunal overturns mental health detention decision