There is exactly one segment out of the six $(X,Y,(X-Y)1_{X-Y}, 1-X,1-Y,(Y-X)1_{Y-X})$ that is the shortest.
Thus the expectation is $\mathbb{E}[\text{whichever is the shortest}]$, and the integral should be carried out over the entire square for each point within the unit square $(x,y) \in [0,1]^2$, using the density $f_{XY}(x,y) = 1$.
That is, with density $f_{XY}(x,y) = 1$ the integrand is not always $x$. There are six regions, and only within one of the regions is the integrand (shortest length) $x$.
At this point, one can recognize the $6$-fold symmetry, and integrates only over the one-sixth region $\{x<\frac13, x<y, x \leq y - x\}$ as shown in the diagram there, then multiply the whole thing by $6$.
In that answer, stating that "the density is $6$" is implicitly considering the conditional expectation $\mathbb{E}[X \mid \text{shortest is $X$}]$. Again, if one were doing this unconditionally, one would need to add $$\mathbb{E}[X\cdot 1_{\text{{$X$ is the shortest}}}]+\mathbb{E}[Y\cdot 1_{\text{{$Y$ is the shortest}}}] + \mathbb{E}[(1-X)\cdot 1_{\text{{$1-X$ is the shortest}}}]+\cdots$$
Here, doing this conditionally one has the conditional density
$$f_{\text{conditional}} = \frac{ f_{\text{joint}} }{ \Pr_{\text{conditional}} } = \frac{ 1 }{ \frac12 \cdot \frac13 } = 6$$
where the $1$ on top is the usual uniform-over-square, the $1/2$ below is for $X<Y$, and the $1/3$ comes from the fact "It's not hard to show that they all have probability $1/3$ of being the shortest."
Allow me to be pedantic.
Since the six segments are interchangeable, all the conditional expectations are the same. Namely, one will arrive at the same answer: $$\mathbb{E}[X \mid \text{shortest is $X$}] = \mathbb{E}[Y \mid \text{shortest is $Y$}] = \mathbb{E}[1-X \mid \text{shortest is $1-X$}] =\cdots$$
The reason that anyone of them gives the desired expectation (that answer by Hans Parshall picked to calculate $\mathbb{E}[X \mid \text{shortest is $X$}]$) is because
\begin{align}
&\hphantom{{}={}}\mathbb{E}[\text{whichever is the shortest}] \\
&= \frac16\mathbb{E}[X \mid \text{shortest is $X$}] + \frac16 \mathbb{E}[Y \mid \text{shortest is $Y$}] + \frac16 \mathbb{E}[1-X \mid \text{shortest is $1-X$}] + \cdots \\
&= 6\cdot\frac16 \mathbb{E}[X \mid \text{shortest is $X$}] \\
&= \mathbb{E}[X \mid \text{shortest is $X$}]
\end{align}