Suppose we have two $n\times n$ matrices $A$ and $B$ with entries in $\mathbb{R}$, and two non-scalar matrices $X$ and $Y$ with entries in $\mathbb{C}$, such that $AX=XA$, $XY=YX$, and $BY=YB$.

Is it necessarily the case that there exist non-scalar matrices $X'$ and $Y'$ with entries in $\mathbb{R}$ such that $AX'=X'A$, $X'Y'=Y'X'$, and $BY'=Y'B$?

(Here "non-scalar" just means that the matrices aren't scalar multiples of the identity matrix.)