# Change of basis: incomplete and overcomplete bases?

Consider two Hilbert spaces $$H_A$$ and $$H_B$$ spanned by the finite eigenbases $$\{|a_k\rangle\}$$ and $$\{|b_j\rangle\}$$ of operators $$\hat A$$ and $$\hat B$$. Given a state $$|\psi\rangle$$ represented in the $$\{|a_k\rangle\}$$ basis, I think the change of basis operation to $$\{|b_j\rangle\}$$ only makes sense when the dimensionality of $$H_A$$ and $$H_B$$ are the same. For instance, if the spectrum of $$\hat A$$ has 100 eigenvalues in it and the spectrum of $$\hat B$$ has three, there is no way I can write 100 linearly independent states in a 3D basis. The bases are overcomplete and incomplete with respect to the states in one Hilbert space or the other. So, my question regards what is the general condition under which a change of basis is well defined?

Given a spin-1 state space, I know we can represent the eigenstates of $$\hat S_j$$ in the eigenstates of $$\hat S_k$$, and it makes sense that there are three eigenstates in each 3D Hilbert space. I can represent position states in infinite dimensional Hilbert space with the basis of the infinite dimensional basis of the Hilbert space of momentum states, etc. No examples come to mind where the change of basis is something more complicated so I hope someone can fill me on on the most general condition. Is equal dimensionality the beginning and the end of the story? I feel like there must be a theorem or something.