I would factor in the time from Main & back.

Run it through MPLAB sim with the stopwatch. Set a break point on Main. Single
step down to Main, clear the Stopwatch, and hit run. The time it takes from
Main & back is the time it takes to complete one full loop & emit 31 bursts.

If you're within the timing specs shown in the data sheet, and it's not working
as expected, then it's most likely something else like ambient lighting, circuit
noise, other components, etc, etc,.

A lot of things affect results with IR, and the data sheet is just a guide. Specs
shown in most data sheets are derived under optimum laboratory conditions for the
part under test.

You'll normally need to make adjustments based in your own particular operating
environment, parts used, final design, and a host of other factors.

With 3 IR LED's all being fired at once, and 3 IR detectors, it's possible that
you have enough bleed over to influence all 3 detectors at once. Even when an
object isn't in front of an LED/detector pair.

At any rate, I wouldn't try pushing it right up to the limits in a data sheet, and
expect it to work continuously. If my car can go 160mph max I'm not going to drive
everywhere I go at that speed...;o}