Hadhrat Shaykh Moulana Muhammad Zakariyya (Rahimahullah) once mentioned :
I will show you the gauge to determine whether a person is among the servants whom Allah Ta‘ala has blessed with His special recognition and friendship, or whether he is merely pretending to be a pious person with the aim of misleading people.
The gauge to determine whether a person is the friend of Allah Ta‘ala is that when he associates with any person and shows mahabbah for him, then his association with him is not based on any personal motive or worldly benefit. If the association is based on any personal motive or worldly benefit, then generally, when the personal motive or worldly benefit is achieved, the friendship ends. True friendship is not based on any personal motive or worldly benefit, but solely for the love of Allah Ta‘ala. Such a friendship is perpetual.
If you measure people through this gauge, then you will be saved from misguidance and problems. Allah Ta‘ala will bless you with His special recognition and guidance. Similarly, He will also assist you divinely to find the right person to guide you in Deen.
Adapted from the writings of Qutbul Aqtaab Hazrat Shaykhul Hadith Moulana Muhammad Zakariyya (rahimahullah)