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.
muslim:1553bʿAbd b. Ḥumayd > Muslim b. Ibrāhīm > Abān b. Yazīd > Qatādah > Anas b. Mālik

Who planted this palm-a Muslim or an unbelievers The rest of the hadith is the same.  

مسلم:١٥٥٣bوَحَدَّثَنَا عَبْدُ بْنُ حُمَيْدٍ حَدَّثَنَا مُسْلِمُ بْنُ إِبْرَاهِيمَ حَدَّثَنَا أَبَانُ بْنُ يَزِيدَ حَدَّثَنَا قَتَادَةُ حَدَّثَنَا أَنَسُ بْنُ مَالِكٍ

أَنَّ نَبِيَّ اللَّهِ ﷺ دَخَلَ نَخْلاً لأُمِّ مُبَشِّرٍ امْرَأَةٍ مِنَ الأَنْصَارِ فَقَالَ رَسُولُ اللَّهِ ﷺ مَنْ غَرَسَ هَذَا النَّخْلَ أَمُسْلِمٌ أَمْ كَافِرٌ قَالُوا مُسْلِمٌ بِنَحْوِ حَدِيثِهِمْ  


See similar narrations below:

Collected by Aḥmad
ahmad:12999Bahz > ʿAffān > Abān > Qatādah > Anas b. Mālik

[Machine] The Prophet ﷺ entered a date palm grove belonging to Umm Mubashir, a woman from the Ansar. He asked, "Who planted this tree? Is it a Muslim or a non-Muslim?" They replied, "It was planted by a Muslim." He said, "A Muslim should not plant a tree from which a human, animal, or bird eats without it being counted as a charity for him."  

أحمد:١٢٩٩٩حَدَّثَنَا بَهْزٌ وَحَدَّثَنَا عَفَّانُ قَالَا حَدَّثَنَا أَبَانُ حَدَّثَنَا قَتَادَةُ حَدَّثَنَا أَنَسُ بْنُ مَالِكٍ

أَنَّ رَسُولَ اللهِ ﷺ دَخَلَ نَخْلًا لِأُمِّ مُبَشِّرٍ امْرَأَةٍ مِنَ الْأَنْصَارِ فَقَالَ مَنْ غَرَسَ هَذَا الْغَرْسَ أَمُسْلِمٌ أَمْ كَافِرٌ؟ قَالُوا مُسْلِمٌ قَالَ لَا يَغْرِسُ مُسْلِمٌ غَرْسًا فَيَأْكُلُ مِنْهُ إِنْسَانٌ أَوْ دَابَّةٌ أَوْ طَائِرٌ إِلَّا كَانَ لَهُ صَدَقَةً