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:9

Kill Joseph or cast him out to ˹another˺ land; the countenance of your father will ˹then˺ be only for you, and you will be after that a righteous people."  

Kill Joseph or cast him away into some land, that is, into some distant land, so that your father might be solely concerned with you, so that he might turn ˹his attention˺ to you and not be distracted by anyone else, and that thereafter, that is, after killing Joseph or casting him away, you might be a righteous folk’, by repenting.
القرآن:١٢:٩

اقْتُلُوا يُوسُفَ أَوِ اطْرَحُوهُ أَرْضًا يَخْلُ لَكُمْ وَجْهُ أَبِيكُمْ وَتَكُونُوا مِنْ بَعْدِهِ قَوْمًا صَالِحِينَ  

{اقتلوا يوسف أو اطرحوه أرضا} أي بأرض بعيدة {يخل لكم وجه أبيكم} بأن يقبل عليكم ولا يلتفت لغيركم {وتكونوا من بعده} أي بعد قتل يوسف أو طرحه {قوما صالحين} بأن تتوبوا.