Why and when can I just peacefully substitute into $\tan^{-1}x+\tan^{-1}y=\tan^{-1}\frac{x+y}{1-xy}$ without checking range conditions? This is an example question in my book:

To solve for $x$:
$$\tan^{-1}\frac{x-1}{x+2}+\tan^{-1}\frac{x+1}{x+2}=\frac{\pi}{4}$$

and it is solved by a direct formula given by
$$\tan^{-1}x+\tan^{-1}y=\tan^{-1}  \left(\frac{x+y}{1-xy}\right) $$ when $xy<1$. The book uses this formula without checking conditions many many times and it is mildly infuriating. It is alright when checking the condition is simple but in this case finding the range of $\dfrac{x^2-1}{(x+2)^2}$ is a little time consuming and has the square root of 21 in it.
Well my question is:

Why and when can I just peacefully substitute the formula without worrying about the condition as the book leisurely does so?

 A: We have,
$\mathsf{tan^{-1}\left(\dfrac{x-1}{x+2}\right)+tan^{-1}\left(\dfrac{x+1}{x+2}\right)=\dfrac{\pi}{4}}$
$\mathsf{\implies\,tan^{-1}\left(\dfrac{x+1}{x+2}\right)=\dfrac{\pi}{4}-tan^{-1}\left(\dfrac{x-1}{x+2}\right)}$
$\mathsf{\implies\,tan\left\{tan^{-1}\left(\dfrac{x+1}{x+2}\right)\right\}=tan\left\{\dfrac{\pi}{4}-tan^{-1}\left(\dfrac{x-1}{x+2}\right)\right\}}$
$\mathsf{\implies\,\dfrac{x+1}{x+2}=\dfrac{1-\dfrac{x-1}{x+2}}{1+\dfrac{x-1}{x+2}}}$
$\mathsf{\implies\,\dfrac{x+1}{x+2}=\dfrac{x+2-x+1}{x+2+x-1}}$
$\mathsf{\implies\,\dfrac{x+1}{x+2}=\dfrac{3}{2x+1}}$
$\mathsf{\implies\,(x+1)(2x+1)=3(x+2)}$
$\mathsf{\implies\,2x^2+2x+x+1=3x+6}$
$\mathsf{\implies\,2x^2+3x+1=3x+6}$
$\mathsf{\implies\,2x^2=5}$
$\mathsf{\implies\,x=\pm\sqrt{\dfrac{5}{2}}}$
Now, check the value(s) of x satisfying the given equation,
Those value(s) of x are not satisfying the given equation, will be neglected
There is no need to work with the conditions when solving ITF equations.
In this equation  $\mathsf{x=-\sqrt{\dfrac{5}{2}}}$  does not satisfy the given equation
Thus,  $\mathsf{x=\sqrt{\dfrac{5}{2}}}$  is the only real solution.
