This image:

from this question says that inverse substitution requires the substitute to be one-to-one.
But whether $g$ is one-to-one or not, I thought one could write
$$ \int f(x)dx = \int f(g(t))g'(t)dt \\ {\textit{or more precisely:}\hspace{12cm}} \\ \int f(x)dx = \left(\int f(g(t))g'(t)dt\right)\circ g^{-1} \\ {\textit{where }g^{-1}\textit{ is any right inverse of g}\hspace{9cm}}$$
though only if the range of $g$ (and its codomain for the right inverse to exist) equals the domain of $f$.
A comment to the linked question suggests considering $g(t) = 0$, but the range of that doesn't equal the domain of any reasonable $f$. The answer in the linked question says:
... consider:
$\int_a^b f(x) dx$ where $f(x)>0 \;\forall x\in (a,b)$
... if our substition is not $1-1$ there exists the possibility that $g^{-1}(b) = g^{-1}(a),$
which confuses me because, to me $g^{-1}(b) = g^{-1}(a)$ means $g$ is not well-defined if $a<b$.
Is everything in the linked question really as wrong as it seems to me?