The idea in your approach almost works. But you cannot assume that $A$ and $B$ have the same eigenvectors! So you will have
$$
Ax_j=\lambda_jx_j,\ \ \ By_j=\lambda_jy_j.
$$
As $\lambda_1,\ldots,\lambda_p$ are distinct, $x_1,\ldots,x_p$ and $y_1,\ldots,y_p$ are each linearly independent, so they are bases. Let $P$ be the change of basis $y\to x$, i.e. $P$ is the matrix such that $Py_j=x_j$, $j=1,\ldots,n$. It is clearly nonsingular: if $P(c_1y_1+\cdots+c_py_p)=0$, then
$$
0=c_1P(y_1)+\cdots+c_pP(y_p)=c_1x_1+\cdots+c_px_p,
$$
so $c_1=\cdots=c_p=0$. Now, for each $j$,
$$
PBy_j=\lambda_j Py_j=\lambda_jx_j=Ax_j=APy_j.
$$
As the $y$ are a basis, we get that $PB=AP$, i.e. $PBP^{-1}=A$.
Let us prove that $Q$ is upper triangular. Let $e_1,\ldots,e_n$ be the canonical basis of $\mathbb{C}^n$. Suppose $a_1,\ldots,a_n$ are the diagonal entries of $U_1$ and $U_2$.
Lemma: Let $P_{n\times n}$ be upper triangular with distinct diagonal entries $a_1,\ldots,a_n$. If $v_i$ is an eigenvector of $P$ associated to $a_i$ then $v_i\in\text{span}\{e_1,\ldots,e_i\}$.
Proof: Since $P$ is upper triangular then $P(\text{span}\{e_1,\ldots,e_i\})\subset\text{span}\{e_1,\ldots,e_i\}$ for every $1\leq i\leq n$. Notice that the eigenvalues of $P|_{\text{span}\{e_1,\ldots,e_i\}}$ are $a_1,\ldots,a_i$. Thus, there is $0\neq w_i\in \text{span}\{e_1,\ldots,e_i\}$ such that $Pw_i=a_iw_i$. Finally, if $v_i$ is an eigenvector of $P$ associated to $a_i$ then $v_i=c w_i$, since the multiplicity of $a_i$ is $1$. Therefore, $v_i\in \text{span}\{e_1,\ldots,e_i\}$. $\square$
Now, let $v_1,\ldots,v_n$ be the eigenvectors of $U_2$ associated to $a_1,\ldots,a_n$, respectively. Since $U_2$ is upper triangular, by the previous lemma, $\text{span}\{v_1,\ldots,v_i\}\subset \text{span}\{e_1,\ldots,e_i\}$.
Now, since $\{v_1,\ldots,v_i\}$ are eigenvectors associated to different eigenvalues then they are L.I. and $\text{span}\{v_1,\ldots,v_i\}= \text{span}\{e_1,\ldots,e_i\}$.
Next, $U_1=QU_2Q^{H}$ and $U_1Qv_i=QU_2Q^{H}Qv_i=QU_2v_i=a_iQv_i$. Therefore, $\{Qv_1,\ldots,Qv_n\}$ are the eigenvectors of $U_1$ associted to $a_1,\ldots,a_n$.
By the previous lemma, $\text{span}\{Qv_1,\ldots,Qv_i\}\subset \text{span}\{e_1,\ldots,e_i\}$.
Finally,$Q(\text{span}\{e_1,\ldots,e_i\})=Q(\text{span}\{v_1,\ldots,v_i\})=\text{span}\{Qv_1,\ldots,Qv_i\}\subset\text{span}\{e_1,\ldots,e_i\}$. This implies that $Q$ is upper triangular.
Best Answer
Since $D$ is diagonal you have $$(DT)_{ij}=D_{ii}T_{ij}, \qquad(TD)_{ij}=T_{ij}D_{jj}$$ so $$(DT-TD)_{ij}=T_{ij}(D_{ii}-D_{jj})\overset!= 0.$$ If $T_{ij}\neq0$ you get $D_{ii}=D_{jj}$, since you are supposing that $D$ only takes on distinct eigenvalues you find $T_{ij}=0$ if $i\neq j$.