Let $(X, \mathcal F, \mu)$ be a $\sigma$-finite measure space and $(E, |\cdot|)$ a Banach space. Here we use the Bochner integral. I would like to prove the following result, i.e.,
Theorem Let $f \in L_1(X, \mu, E)$, $\mathcal A := \{A \in \mathcal F : \mu(A) \in (0, \infty)\}$, and $$ \varphi(A) := \frac{1}{\mu(A)} \int_A f \mathrm d \mu \quad \forall A \in \mathcal A. $$ Let $G$ be a non-empty closed subset of $\mathbb R$. If $|\varphi (A)| \in G$ for all $A \in \mathcal A$ then $|f(x)| \in G$ for almost all $x \in X$.
Could you have a check on my attempt?
Proof: We need the following related result, i.e.,
Lemma Let $f \in L_1(X, \mu, E)$ and $F$ be a non-empty closed subset of $E$. If $$ \varphi(A) :=\frac{1}{\mu(A)} \int_A f \mathrm d \mu \in F \quad \forall A \in \mathcal F \text{ s.t. } \mu(A) \in (0, \infty), $$ then $f(x) \in F$ for almost all $x \in X$.
Let $F := \{e \in E : |e| \in G\}$. Because the norm is continuous and $F$ is closed, we get $G$ is closed. Also, $\varphi (A) \in F$ for all $A \in \mathcal A$. By our Lemma, $f(x) \in F$ and thus $|f(x)| \in G$ for almost all $x \in X$. This completes the proof.