In a proof of the equivalence of the canonical and grand canonical ensembles (in the thermodynamic limit) in Jochen Rau's Statistical Physics and Thermodynamics (highly recommended!), the author evaluates the grand canonical partition function as $$Z_G = \textrm{Tr}(\exp(-\beta \hat{H} + \alpha \hat{N})).$$ In evaluating this trace, it seems to me that the author uses a joint eigenbasis of $\hat{H}$ and $\hat{N}$ and, thus, the fact that they commute.
My question is, what sorts of restrictions exist on $\hat{H}$ (i.e. on the type of system to which this implies) for $[\hat{H},\hat{N}] = \hat{0}$?