Let $U,H$ be complex Hilbert spaces, $(e_n)_{n\in\mathbb N}$ be an orthonormal basis of $U$, $(\lambda_n)_{n\in\mathbb N}\subseteq(0,\infty)$ be nondecreasing and $$f_n:=\sqrt{\lambda_n}e_n\;\;\;\text{for }n\in\mathbb N.$$
Assume that $U$ is compactly and densely embedded into $H$ and $$\langle u,e_i\rangle_U=\lambda_i\langle u,e_i\rangle_H\tag1\;\;\;\text{for all }u\in U\text{ and }i\in\mathbb N.$$ Are we able to conclude that $(f_n)_{n\in\mathbb N}$ is an orthonormal basis of $H$?
We would need to show that if $x\in\{f_i:i\in\mathbb N\}^{\perp_H}$, then $x=0$. Since $U$ is densely embedded into $H$, there is a $(u_n)_{n\in\mathbb N}$ with $$\left\|u_n-x\right\|_H\xrightarrow{n\to\infty}0\tag2.$$ So, $$0=\langle x,f_i\rangle_H=\lim_{n\to\infty}\langle u_n,f_i\rangle_H=\frac1{\sqrt\lambda_i}\lim_{n\to\infty}\langle u_n,e_i\rangle_U\tag3.$$ But I'm not able to proceed from here ...
Let $E:=span\{ e_i:i\in \mathbb N\}$. Then by assumption $E$ is dense in $U$ with respect to $\|\cdot\|_U$. Since $U$ is continuously embedded into $H$, it follows $E$ is dense in $U$ with respect to $\|\cdot\|_H$. By assumption $U$ is dense in $H$ with respect to $\|\cdot\|_H$. This implies $E$ is dense in $U$ with respect to $\|\cdot\|_H$. And $E^{\perp H}=\{0\}$.