Foam is remarkably effective in the mobility control of gas injection for enhanced oil recovery (EOR) processes and CO2 sequestration. Our goal is to better understand immiscible three-phase foam displacement with oil in porous media. In particular, we investigate (i) the displacement as a function of initial (I) and injection (J) conditions and (ii) the effect of improved foam tolerance to oil on the displacement and propagation of foam and oil banks. We apply three-phase fractional-flow theory combined with the wave-curve method (WCM) to find the analytical solutions for foam-oil displacements. An n-dimensional Riemann problem solver is used to solve analytically for the composition path for any combination of J and I on the ternary phase diagram and for velocities of the saturations along the path. We then translate the saturations and associated velocities along a displacement path to saturation distributions as a function of time and space. Physical insights are derived from the analytical solutions on two key aspects: the dependence of the displacement on combinations of J and I and the effects of improved oil-tolerance of the surfactant formulation on composition paths, foam-bank propagation and oil displacement. The foam-oil displacement paths are determined for four scenarios, with representative combinations of J and I that each sustains or kills foam. Only an injection condition J that provides stable foam in the presence of oil yields a desirable displacement path, featuring low-mobility fluids upstream displacing high-mobility fluids downstream. Enhancing foam tolerance to oil, e.g. by improving surfactant formulations, accelerates foam-bank propagation and oil production, and also increases oil recovery. Also, we find a contradiction between analytical and numerical solutions. In analytical solutions, oil saturation (So) in the oil bank is never greater than the upper-limiting oil saturation for stable foam (fmoil in our model). Nevertheless, in numerical simulations, So may exceed the oil saturation that kills foam in the oil bank ahead of the foam region, reflecting a numerical artifact. This contradiction between the two may arise from the calculation of pressure and pressure gradient using neighboring grid blocks in a numerical simulation. The analytical solutions we present can be a valuable reference for laboratory investigation and field design of foam for gas mobility control in the presence of oil. More significantly, the analytical solutions, which are free of numerical artifacts, can be used as a benchmark to calibrate numerical simulators for simulating foam EOR and CO2 storage processes.