Showing a function is invertible I came across this problem and not sure how to prove it.

Show that if $ f\circ f \circ g\circ g \circ f\circ f $ is invertible then $ g $ is invertible.

I'm not sure if it's correct to say that  $f$ is invertible because it's the most left function and then show that $g$ is invertible.

Let $h$ be an inverse for $f\circ f \circ g\circ g \circ f\circ f$.
$id=(f\circ f \circ g\circ g \circ f\circ f)\circ h=f\circ (f \circ g\circ g \circ f\circ f\circ h)$ implies that $f$ is surjective.
$id=h\circ (f\circ f \circ g\circ g \circ f\circ f)=(h\circ f\circ f \circ g\circ g \circ f)\circ f$ implies that $f$ is injective.
Thus, $f$ is a bijection and so has an inverse $f'$.
Then
$g\circ g = f' \circ f' \circ (f\circ f \circ g\circ g \circ f\circ f) \circ f' \circ f'$.
This implies that $g\circ g$ is invertible, because it is the composition of invertible functions.
Finally, $g$ is invertible by repeating the argument used for $f$.
More precisely, let $k$ be an inverse for $g\circ g$. Then:
$id=(g\circ g) \circ k= g\circ (g \circ k)$
implies that $g$ is surjective.
$id=k \circ(g\circ g)=(k \circ g)\circ g$
implies that $g$ is injective.
Thus, $g$ is a bijection and so invertible.
More generally,

If $F \circ G \circ F$ is invertible, then $F$ and $G$ are invertible.

Apply this once to $F=f \circ f$ and $G=g\circ g$ and get that $g\circ g$ is invertible.
Apply it again to $F=g$ and $G=id$ and get that $g$ is invertible.
