On one occasion in battle, Usama ibn Zayd killed a man who had uttered the testimony of faith. The Messenger ﷺ challenged his assumption about the man's intention:
أَفَلَا شَقَقْتَ عَنْ قَلْبِهِ حَتَّى تَعْلَمَ أَقَالَهَا أَمْ لَا؟
Did you open his heart to know whether he said it sincerely or not? (Sahih Muslim)
A person cannot claim certain knowledge of another's hidden conviction. Outward profession governs earthly treatment; the true state of the heart is known to Allah.