Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:12:89

He said, "Do you know what you did with Joseph and his brother when you were ignorant?"  

Then, he said, to them, in rebuke: ‘Do you realise what you did to Joseph, in the way of beating ˹him˺ and selling ˹him˺ and otherwise, and his brother, oppressing him, after having separated him from his brother, while you were ignorant?’, of where the affair of Joseph will lead?
القرآن:١٢:٨٩

قَالَ هَلْ عَلِمْتُمْ مَا فَعَلْتُمْ بِيُوسُفَ وَأَخِيهِ إِذْ أَنْتُمْ جَاهِلُونَ  

ثم {قال} لهم توبيخا {هل علمتم ما فعلتم بيوسف} من الضرب والبيع وغير ذلك {وأخيه} من هضمكم له بعد فراق أخيه {إذ أنتم جاهلون} ما يئول إليه أمر يوسف.