Can someone please explain why this is a wrong answer: Când ei au scris o scrisoare
It is correct. This app is sometimes a mess.
This app is most of the time a mess.
It sounds like you are saying "When they wrote a letter..." and that you will continue the sentence instead of ask "When did they write a letter?"
99% of the time, Duo does not invert for questions. 1% of the time, it marks you wrong unless you do. This is an example of the 1%.