Let $(\Omega,\mathcal{F}, P)$ be a probability space, $\mathbb{F}=(\mathcal{F}_t)_{t\in [0,T]}$ be a filtration. Let $X$ be $\mathcal{F}_0$-measurable and $Y:[0,T]\to \mathbb{R}$ be $\mathbb{F}$-adapted (i.e., $Y_t$ is $\mathcal{F}_t$-adapted). Then I was wondering that assuming $f$ is a continuous and bounded function such that $f(x,\mathbb{R})=\{f(x,y)\mid y\in \mathbb{R}\}$ is convex, can I choose an $\mathcal{F}_0$-measurable random variable $Z:\Omega\to \mathbb{R}$ such that $$ \mathbb{E}\left[\int_0^T f(X,Y_s)ds\right]=T\mathbb{E}[f(X,Z)]. \tag{1} $$
The difficulty is to construct $Z$ with the desired measurability. My intuition is to consider $\mathbb{E}\big[\int_0^T f(X,Y_s)ds\big]=\mathbb{E}\big[\mathbb{E}\big[\int_0^T f(X,Y_s)ds\mid \mathcal{F}_0\big]\big]$. If $$\int_0^T \mathbb{E}\left[f(X,Y_s)\mid \mathcal{F} _0\right]ds =T f(X,Z)$$ for some $\mathcal{F}_0$-measurable $Z$, then the desired identity holds. I feel the condition $f(x,\mathbb{R})=\{f(x,y)\mid y\in \mathbb{R}\}$ and mean-value theorem should allow for representing the conditional expectation as a random variable, but I am not sure whether the argument can be made rigorously.