If $X$ is $\sigma(\mathcal{G} \cup \mathcal{H})$-measurable can we write $X=f(G,H)$? Let $(\Omega, \mathcal{F}, P)$ be a probability triplet.  Let $\mathcal{G}$ and $\mathcal{H}$ be two sub-sigma-algebras of $\mathcal{F}$. Let $X:\Omega\rightarrow\mathbb{R}$ be a random variable such that
$\sigma(X) \subseteq \sigma(\mathcal{G} \cup \mathcal{H})$.
Can we say there is a Borel-measurable function $f:\mathbb{R}^2\rightarrow\mathbb{R}$ and two random variables $G$ and $H$ such that
$X = f(G,H)$, and $\sigma(G) \subseteq \mathcal{G}$, $\sigma(H) \subseteq \mathcal{H}$?  Are there references where I can cite such a result?
If it makes the problem easier, I am also interested in the case when $\mathcal{G}$ and $\mathcal{H}$ are independent and/or when one of the sub-sigma-algebras, say $\mathcal{G}$, is generated by some random variable $R$.

Note 1: I can show it is true if there are random variables $R, S$ such that $\mathcal{G}=\sigma(R)$ and $\mathcal{H}=\sigma(S)$.
Note 2: There may be some hope by applying properties of countably generated sigma algebras, since $\sigma(X)$ is countably generated. If we define the events $B_x = \{X \leq x\}$ for each rational number $x$, I wonder if there is a way of writing a particular event $B_x$ in terms of events in $\mathcal{G}$ and $\mathcal{H}$.

Application: I have a random variable $Z$ and I want to write for some $f$:
$$ E[Z|\sigma(\mathcal{G} \cup \mathcal{H})] \overset{?}{=} f(G,H)$$
This is similar in spirit to the known fact $E[Z|\sigma(Y)]=f(Y)$ for some $f$.

What is true, and this may be sufficient for your purposes, is that under the stated conditions there is a $\mathcal G\otimes\mathcal H$-measurable map $Z:\Omega\times\Omega\to\Bbb R$ such that $X(\omega) = Z(\omega,\omega)$ for all $\omega\in\Omega$. (And conversely, because  $\omega\mapsto(\omega,\omega)$ is $\sigma(\mathcal G\cup\mathcal H)/\mathcal G\otimes\mathcal H$-measurable.)
