I'm not sure scanning the boarding pass triggers the earned miles.
I recently boarded an AA flight that subsequently pulled away from the gate and then returned before taking off because of a mechanical failure. I wound up de-boarding and taking another AA flight (different routing), and I did not get credit for the original flight.
However, I have also been on an AA flight that has taken off, run into a mechanical problem immediately after take off, and returned to the originating airport. I was re-booked on another flight (TWA when it was in the process of being acquired by AA), and I got credit for the original AA flight and the TWA flight.
Is take-off perhaps the trigger?