Surah Yusuf

12:79

قَالَ مَعَاذَ ٱللَّهِ أَن نَّأْخُذَ إِلَّا مَن وَجَدْنَا مَتَٰعَنَا عِندَهُۥٓ إِنَّآ إِذًۭا لَّظَٰلِمُونَ

He said, "[I seek] the refuge of Allah [to prevent] that we take except him with whom we found our possession. Indeed, we would then be unjust."

Tafsir 12:79

Joseph asked for protection from Allah that they should wrong someone innocent with the sin of a wrongdoer. If they took someone other than the person in whose bag they found the bowl of the king, then they would be wrongdoers, because they would be punishing someone who was innocent and letting a criminal go free.