Oof… it looks great, don’t get me wrong!
This is just inconvenient! You didn’t leave enough pipe between sockets to reliably get a new fitting on the remaining pipe stub, so this may be tricky…
The gold standard would be to get a duplicate union fitting and use only half of it, coupling to the existing union half, and rebuilding all downstream plumbing… but, that’s expensive!!
You MIGHT be able to get a fitting to glue and seal if you cut the last elbow/valve off… give yourself the longest residual pipe stub possible, and use a nice, thick glue… possibly even cut down the length of the cap socket (given that it tapers)…