Known problem for several versions (it was introduced in 7.3 where the ubb code handling was rewritten). Any ubb code nested 4 levels deep goes wrong.
I've kludged around the problem by embracing it

I don't like quotes in quotes in quotes.
I made a mod that actually displays an error to the user if they "deepquote" too much.
https://www.ubbdev.com/forums/ubbthreads.php/topics/317183