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

Allah only forbids you from those who fight you because of religion and expel you from your homes and aid in your expulsion - ˹forbids˺ that you make allies of them. And whoever makes allies of them, then it is those who are the wrongdoers.  

God only forbids you in regard to those who waged war against you on account of religion and expelled you from your homes and supported ˹others˺ in your expulsion, that you should make friends with them (an tawallawhum is an inclusive substitution for alladhīna, ‘those who’). And whoever makes friends with them, those — they are the wrongdoers.
القرآن:٦٠:٩

إِنَّمَا يَنْهَاكُمُ اللَّهُ عَنِ الَّذِينَ قَاتَلُوكُمْ فِي الدِّينِ وَأَخْرَجُوكُمْ مِنْ دِيَارِكُمْ وَظَاهَرُوا عَلَىٰ إِخْرَاجِكُمْ أَنْ تَوَلَّوْهُمْ ۚ وَمَنْ يَتَوَلَّهُمْ فَأُولَٰئِكَ هُمُ الظَّالِمُونَ  

{إنما ينهاكم الله عن الذين قاتلوكم في الدين وأخرجوكم من دياركم وظاهروا} عاونوا {على إخراجكم أن تولوهم} بدل اشتمال من الذين، أي تتخذونهم أولياء {ومن يتولهم فأولئك هم الظالمون}.