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:6:52

And do not send away those who call upon their Lord morning and afternoon, seeking His countenance. Not upon you is anything of their account and not upon them is anything of your account. So were you to send them away, you would ˹then˺ be of the wrongdoers.  

And do not drive away those who call upon their Lord at morning and evening desiring, through their worship, His countenance, exalted be He, and not ˹desiring˺ any of the transient things of this world — and these are the poor. The idolaters had reviled them and demanded that he ˹the Prophet˺ expel them, so that they could sit with him. The Prophet (s) wanted ˹to do˺ this, because of his desire that they become Muslims. You are not accountable for them in anything (min shay’in: min is extra), if what they hide in themselves be displeasing; nor are they accountable for you in anything, that you should drive them away (this is the response to the negative sentence) and be of the evildoers, if you do this.
القرآن:٦:٥٢

وَلَا تَطْرُدِ الَّذِينَ يَدْعُونَ رَبَّهُمْ بِالْغَدَاةِ وَالْعَشِيِّ يُرِيدُونَ وَجْهَهُ ۖ مَا عَلَيْكَ مِنْ حِسَابِهِمْ مِنْ شَيْءٍ وَمَا مِنْ حِسَابِكَ عَلَيْهِمْ مِنْ شَيْءٍ فَتَطْرُدَهُمْ فَتَكُونَ مِنَ الظَّالِمِينَ  

{ولا تطرد الذين يدعون ربَّهم بالغداة والعشي يريدون} بعبادتهم {وجهه} تعالى لا شيئا من أعراض الدنيا وهم الفقراء، وكان المشركون طعنوا فيهم وطلبوا أن يطردهم ليجالسوه وأراد النبي ﷺ ذلك طمعا في إسلامهم {ما عليك من حسابهم من} زائدة {شيء} إن كان باطنهم غير مرضي {وما من حسابك عليهم من شيء فتطردهم} جواب النفي {فتكون من الظالمين} إن فعلت ذلك.