What a mass airflow sensor actually does
A mass airflow sensor sits in the intake tube after the filter. Hot film or hot wire. The PCM reads that cooling and meters fuel. It is not a MAP sensor and not a throttle body.
Air comes in through the filter and into the duct. That is where the mass airflow sensor sits — a hot film or a hot wire in the tube, after the paper, before the throttle. It is not the throttle body. It is not a MAP sensor. MAP reads pressure in the manifold. This one reads how much air is actually moving.

A current holds that film or wire a little above the incoming air. More mass cools it faster. The box adds current to keep the temperature. That current is the signal. The PCM reads it as load and meters fuel. Less air, less fuel. More air, more fuel.

Oil from an over-oiled filter films the element. Dirt does the same. A loose connector drops the signal and puts it back. The mix goes lean or rich. The idle surges. The codes follow this sensor, not the injectors.

Do not start at the throttle body because the scanner said airflow. Pull the duct. Look at the film. That is the part that cooled.