Context: these lecture notes, exercise 47. Not a homework assignment.
$(X,\mathcal{F},\mu)$ is a probability space, $T:X\rightarrow X$ is a probability preserving map. Define $$\mathcal{G}:= \sigma (\{A\in \mathcal{F}:T^{-1}(A)=A\}).$$ Prove that $\mathcal{G}$-measurable RV's are $T$-invariant (i.e. $f\circ T = f,$ $\mu$ almost everywhere).
My attempt: $$T^{-1}(A) = A \implies A = T(A)$$ $$\implies f(T(A)) = f(A).$$
So when restricted to the generators of $\mathcal{G}$, $f\circ T=f$. How can I extend this to the whole $\sigma$-algebra?