We study lepto- and hadroproduction of a heavy-quark pair in the ITMD factorization framework for dilute-dense collisions. Due to the presence of a nonzero quark mass and/or nonzero photon virtuality, new contributions appear compared to the cases of photo- and hadroproduction of dijets, for which the ITMD framework was originally derived. The extra terms are sensitive to gluons that are not fully linearly polarized. At small $x$ those gluons emerge only when saturation effects are taken into account, and in a proper way. As a result, in linear small-$x$ frameworks where gluon are fully linearly polarized, such contributions are absent. We show however that they are not always negligible, even for large gluon transverse momentum, due to the behavior of the off-shell hard factors.