Let $g: [0, 1] \to \mathbb R$ be a Lebesgue-measurable function (in the classical sense: the inverse images of Borel sets are Lebesgue-measurable). It is a classical fact in analysis that $f \circ g$ is Lebesgue-measurable as soon as $f$ is continuous, for instance, or Borel-measurable (the inverse images of Borel sets are Borel), but not necessarily if $f$ is only Lebesgue-measurable. My question is: what is the sharpest assumption that one can put on $f$ guaranteeing that $f \circ g$ is Lebesgue-measurable for every Lebesgue-measurable $g$?

More precisely, consider the class $$ \begin{aligned} \mathcal F = \{f: \mathbb R \to \mathbb R \mid {} & g: [0, 1] \to \mathbb R \text{ is Lebesgue-measurable} \implies \\ & f \circ g \text{ is Lebesgue-measurable}\}. \end{aligned} $$ $\mathcal F$ contains all Borel-measurable functions, but does it contain other functions? Or is it equal to the set of all Borel-measurable functions?

This question looks quite natural and I imagined there should be some classical result in real analysis providing its answer, but I could not find it in standard textbooks. I initially conjectured that $\mathcal F$ coincides with the set of all Borel-measurable functions. This would mean that, if $f$ is not a Borel-measurable function, then there exists a Lebesgue-measurable $g$ such that $f \circ g$ is not Lebesgue-measurable. The idea would be to pick such an $f$, pick a Borel set $A$ such that $B = f^{-1}(A)$ is not Borel, and try to construct a *Lebesgue-measurable* $g$ such that $g^{-1}(B)$ is *not* Lebesgue-measurable, but I cannot see how to construct such a $g$ while keeping its Lebesgue-measurability. Any ideas or any references to this question?

**Edit:** made the statements about Lebesgue- or Borel-measurability more precise.