Ibn Maajah (4245) narrated from Thawbaan (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “I certainly know people of my ummah who will come on the Day of Resurrection with good deeds like the mountains of Tihaamah, but Allaah will make them like scattered dust.” Thawbaan said: O Messenger of Allaah, describe them to us and tell us more, so that we will not become of them unknowingly. He said: “They are your brothers and from your race, worshipping at night as you do, but they will be people who, when they are alone, transgress the sacred limits of Allaah.”
This is a saheeh hadeeth; it was classed as such by al-Buwaysari in Misbaah al-Zujaajah (4/246) and al-Albaani in al-Saheehah. Al-Mundhiri said in al-Targheeb wa’l-Tarheeb (3/170): Its narrators are thiqaat (trustworthy).
Ibn Hajar al-Haythami (may Allah have mercy on him) in al-Zawaajir (3/49) regarded it as pretending to be righteous outwardly and transgressing the sacred limits; even committing minor sins when one is alone is regarded as something major, and he quoted this hadeeth as evidence, and said: The one whose habit is to make a show of being good and concealing his evil ways causes more harm and misguidance to the Muslims, because he has no piety and no fear of Allah. End quote.
Repentance to Allah, if it is sincere, erases what came before it of sin, no matter what that sin is. Allah says (interpretation of the meaning):
“Verily, Allaah forgives not that partners should be set up with Him (in worship), but He forgives except that (anything else) to whom He wills; and whoever sets up partners with Allaah in worship, he has indeed invented a tremendous sin”
“Say: ‘O ‘Ibaadi (My slaves) who have transgressed against themselves (by committing evil deeds and sins)! Despair not of the Mercy of Allaah, verily, Allaah forgives all sins. Truly, He is Oft‑Forgiving, Most Merciful.
54. ‘And turn in repentance and in obedience with true Faith (Islamic Monotheism) to your Lord and submit to Him (in Islam) before the torment comes upon you, (and) then you will not be helped.
55. ‘And follow the best of that which is sent down to you from your Lord (i.e. this Qur’aan, do what it orders you to do and keep away from what it forbids), before the torment comes on you suddenly while you perceive not!’
Allaah listed the major sins and immoral actions which He and His righteous close friends disdain, then He said (interpretation of the meaning):
“Except those who repent and believe (in Islamic Monotheism), and do righteous deeds; for those, Allaah will change their sins into good deeds, and Allaah is Oft‑Forgiving, Most Merciful”
Al-Harawi (may Allah have mercy on him) said:
Repentance cannot be sound except with three things: restoring the rights of others, feeling regret for his sins and striving to make up for what he missed of good deeds.
Ibn al-Qayyim said:
Restoring the rights of others means: repenting from the sins that he committed against Allah, and paying off the dues that he owes to other people.
Feeling regret for his sins means: may be interpreted in two ways: (i) feeling sad for his sins, which is indicative of his turning back towards Allah, unlike one who is not upset by his sin, which is indicative of the corruption and deadening of his heart; (ii) being upset by his brother's sins, so that it is as if he is the one who has done it, and he does not rejoice in his brother's misfortune. This is indicative of the softening of his heart and his love of Allah.
Striving to make up for what he missed: this means catching up with what he has missed out on acts of worship and drawing close to Allah, by doing acts similar to them or better than them, especially for what is rest of his life, when the time of his meeting Allah draws near. End quote.
Madaarij al-Saalikeen, 1/434
For more information please see the answer to question number 46683.
And Allah knows best.