I would like some help with the proof of the preservation of measurable cardinals in mild extensions, as I am a bit new with forcing.

By mild extensions, I mean the generic extension produced from a forcing notion of size less than $\kappa$, where $\kappa$ is a large cardinal (in my question measurable). I am reading the proof from Levy-Solovay's article "Measurable Cardinals and the Continuum Hypothesis" (1967). The idea of the proof is that if $U$ is a non-principal, $\kappa$-complete ultrafilter on $\kappa$ (in $V$), then $W=\{X\subseteq \kappa:\exists Y\in U(Y\subseteq X)\}$ is a non-principal $\kappa$-complete ultrafilter on $\kappa$ in $V[G]$. Levy & Solovary use ideals instead of filters, which requires only slight modifications.

I am confused at the part where we try to prove that $W$ is an ultrafilter. Here is what I understand. If $X\subseteq \kappa$ in $V[G]$, let $p$ be such that $p\Vdash \dot{X}\subseteq \kappa$; we define the set of potential values of $X$ in $V$: $$T=\{\alpha<\kappa:\exists q\leq p(q\Vdash \alpha\in \dot{X})\}. $$ $T$ is a subset of $\kappa$ in $V$, so either $T\in U$ or $T\not\in U$. Now somehow we have to show that $T\in U$ implies $X\in W$ and $T\not\in U$ implies $X\not\in W$ (and this is the points where I am stuck). Can you please help me with this argument?