Suppose $K={\mathbb{Q}}(\sqrt{m})$ is a real quadratic field which contains a totally positive fundamental unit $\epsilon$ (hence its norm is $1$). Suppose that $\epsilon \equiv 1 \pmod 8$, so that the quadratic extension $K(\sqrt{\epsilon})$ is unramified over $K$. In particular, it is contained in the genus field; i.e., there exists $d \mid m$ such that $K(\sqrt{\epsilon}) = K(\sqrt{d})$. Is there a recipe for $d$ in terms of $\epsilon$?
A guess: suppose $m$ is odd; then for each odd prime $p \mid m$ let $\tilde{p}$ denote the unique ideal in $K$ dividing $p$, so in particular $\epsilon \equiv \pm 1 \pmod{\tilde{p}}$. Is it true that $d = \prod p$ where the product is over the primes dividing $m$ where $\epsilon \equiv 1$ (or $-1$ as $d$ and $m/d$ give the same extension)?