Suppose I have a group $G$ which is the (inner) direct product of subgroups $H$ and $K$.

That is, $G = HK$, $H\cap K = \{1\}$, and $H$ and $K$ are both normal subgroups of $G$.

Then for a subgroup $G'$ of $G$, I want to write (in fact a proof I'm trying to follow uses this fact) that $G' = (G'\cap H)(G'\cap K)$.

This looks like it should be true in general. $(\supset)$ is clear, but $(\subset)$ won't work out for me.

Suppose $m\in G'$. Then write $m = hk$ for some $h\in H$, $k\in K$. If $h\in G'$, then so is $k$. Similarly if $k\in G'$, then so is $h$. The case left to deal with is if $h,k$ are both not in $G'$. I cannot rule this out.

Extra hypothesis (in the context of the theorem) that might help: $G'$ is a maximal subgroup of $G$ and $H$ and $K$ are both Sylow subgroups of $G$. $G$ is a finite group.