So Allah knows everything's end and eventuality. Al Akhir has Knowledge of all Zahir and Batin because He knows everyone's Nafs. Nafs is for Marifat. So if the person stays on the right path, following beloved Rasoolallah (s) and the Ambiya (as), then Allah is pleased with them. Allah is Aware of everything.
If someone is in the wrong but prays for Hidayat, Allah gives them Hidayat. But if someone is happy to be on the devils path, this Displeases Him very much. This is the Halakat of one's own Nafs.