Right so that's not a airflow sensor. That's just another O2 sensor pre catalytic converter. Often there are ones before and after the cat so it can tell how the cat is operating.
If the message means the post cat sensor, then yeah they've replaced the wrong one.
They might be the same part though so if you have the "faulty" one they pulled out you might be able to put it back in.
"P1166 Meaning: Primary HO2S" to me would mean the pre-cat one to me though so I'd say they've replaced the right one based on the code actually.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)