https://support.apple.com/en-us/HT201557 > Have your Apple ID password ready. For some repairs, you'll need your Apple ID password to erase your device and turn off Find My iPhone.*
> * If you're unable to turn off Find My iPhone, Apple might not be able to service your device. This policy is in force to prevent unauthorized persons from servicing your device without your knowledge. If you don't remember your Apple ID and Password, please go to iForgot.
If the screen was working I think the right thing to have done was just wipe the phone and give it to them. If it was not working that’s a tough spot.
If you wipe your phone before repair they should be able to do what they need to do without having your passcode.
In 2017 I was working in a Service Desk. Whenever an employee needed repair of their work phone we would ask them to wipe it before we sent it away to the repair company.
If that's not the case, the staff need to be retrained and be well versed in what privacy actually means.