Whether your deeds are accepted now, or were ever accepted before, or will remain accepted till you die is a question that Allah, and only Allah knows. No human can judge on the specificity of your situation based on their own knowledge alone.
Having said that, the hadith you are referring to is a hadith that is narrated in Sunan Ibn Mājah as a good (hassan) hadith, and it was authenticated by
Muhammad Nasiruddin al-Albani in his book Sahīh wa Da'īf Sunan Ibn Mājah (Arabic: صحيح وضعيف سنن ابن ماجة). The text of the hadith is:
عَنْ ثَوْبَانَ عَنِ النَّبِيِّ ﷺ أَنَّهُ قَالَ
لأَعْلَمَنَّ أَقْوَامًا مِنْ أُمَّتِي يَأْتُونَ يَوْمَ الْقِيَامَةِ بِحَسَنَاتٍ أَمْثَالِ جِبَالِ تِهَامَةَ بِيضًا فَيَجْعَلُهَا اللَّهُ عَزَّ وَجَلَّ هَبَاءً مَنْثُورًا
قَالَ ثَوْبَانُ: يَا رَسُولَ اللَّهِ صِفْهُمْ لَنَا جَلِّهِمْ لَنَا أَنْ لاَ نَكُونَ مِنْهُمْ وَنَحْنُ لاَ نَعْلَمُ. قَالَ
أَمَا إِنَّهُمْ إِخْوَانُكُمْ وَمِنْ جِلْدَتِكُمْ وَيَأْخُذُونَ مِنَ اللَّيْلِ كَمَا تَأْخُذُونَ وَلَكِنَّهُمْ أَقْوَامٌ إِذَا خَلَوْا بِمَحَارِمِ اللَّهِ انْتَهَكُوهَا
It was narrated from Thawban that the Prophet ﷺ said:
I certainly know people of my nation who will come on the Day of Resurrection with good deeds like the mountains of Tihamah, but Allah will make them like scattered dust.
Thawban said: "O Messenger of Allah, 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, worshiping at night as you do, but they will be people who, when they are alone, transgress the sacred limits of Allah.
Sunan Ibn Majah » Zuhd » Book 37 » Hadith 4386
For your information, there are some scholars who argued about the authenticity of the hadith, but this is not the main topic of the question. So I will assume that the hadith is authentic for the purpose of this answer.
This hadith is worded in what is called muqayyad (Arabic: مقيد), rather mutlaq (Arabic: مطلق). This means it is not a description at large, but aimed at a group of people that are:
- Have an appearance of piety in public
- When they get a chance to sin in the privacy of their own company (groups), they do so with
a. No respect for or fear of Allah
b. Trivializing their sins and their consequences.
It is not talking about one person sinning in the privacy of their own lodging, which would practically describe the entire Muslim population, save for a few that Allah's mercy prevents them from doing so.
What are the interpretations of the hadith?
Several scholars, when interpreting this hadith, say it is describing the signs of the onset of hypocrisy of actions. In Al-Baqarah 2:14, Allah describes the hypocrites (as a group of people, not individually) as doing exactly that: displaying a public image that does not befit their actions when they are among themselves (whom Allah describes as devils). For example (not a conclusive list):
- In Sharh Zād al-Mustanqa' (Arabic: شرح زاد المستقنع), al-Shanqīti explained that the hadith is referring to a group of people that do not take Allah seriously, unlike the group of Muslims slipped into sin during the battle of Uhud, and Allah forgave them (see Al-'Imran 3:155). He elaborates that it is about a group of people that do not attribute to Allah due grandeur; not about people who sin, then regret their sins, then repent.
- Ibn Hajar al-Haytami (Arabic: ابن حجر الهيتمي) explained in Kabira 365 (pp.454 for this online version) that people who are accustomed to display a facade of piety in public only make their sins in private magnify the harm, as this indicates that there is no appropriate level of fear of Allah, and they entice others to do the same.
- How could they entice others if their actions were in private? Muhammad Nasiruddin al-Albani explained that the hadith is not talking about someone alone in the privacy of his own lodging committing a sin, but to the groups of people (Arabic: أقوام), and that the word khālaw (Arabic: خلوا) does not mean in secrecy, but means when they get a chance. You can refer to
In summary, the hadith is not about sinners in general, but about a specific group of people that display an image of piety, then sin when they get the chance, and while being alone among themselves. They sin out of lack of due respect to or fear of Allah, and accordingly they do not repent.
Should I then make my sins public?
It may appear that if one makes one's sins public, one would not be classified among the transgressors who commit sins in secrecy, or in the privacy of their own groups. Hence, the hadith quoted would not apply to them.
It is definitely not the right approach. While doing sins in private could indicate an inappropriate level of fear of Allah, publicizing sins could tempt other Muslims to commit the same, and it could also indicate an inappropriate level of fear of Allah. The Prophet ﷺ told us that we can all be forgiven, except those who disclose sins that Allah has shielded from others:
عَنْ سَالِمِ بْنِ عَبْدِ اللَّهِ، قَالَ سَمِعْتُ أَبَا هُرَيْرَةَ، يَقُولُ سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ
كُلُّ أُمَّتِي مُعَافًى إِلاَّ الْمُجَاهِرِينَ، وَإِنَّ مِنَ الْمَجَانَةِ أَنْ يَعْمَلَ الرَّجُلُ بِاللَّيْلِ عَمَلاً، ثُمَّ يُصْبِحَ وَقَدْ سَتَرَهُ اللَّهُ، فَيَقُولَ يَا فُلاَنُ عَمِلْتُ الْبَارِحَةَ كَذَا وَكَذَا، وَقَدْ بَاتَ يَسْتُرُهُ رَبُّهُ وَيُصْبِحُ يَكْشِفُ سِتْرَ اللَّهِ عَنْهُ
Narrated Abu Huraira, I heard Allah's Messenger ﷺ saying:
All the sins of my followers will be forgiven except those of the Mujahirin (those who commit a sin openly or disclose their sins to the people). An example of such disclosure is that a person commits a sin at night and though Allah screens it from the public, then he comes in the morning, and says, 'O so-and-so, I did such-and-such (evil) deed yesterday,' though he spent his night screened by his Lord (none knowing about his sin) and in the morning he removes Allah's screen from himself.
Sahih al-Bukhari 6069
Islam offers us a practical set of teachings. The target is to never sin, but this is practically impossible, so Allah offers us a way to correct previous mistakes, and have such sins discounted. This is through repenting, which is comprised of regretting one's action, asking Allah for forgiveness of past sins, and resolving not to commit such sins again (and to mend what was damaged if the action involved other people). If we do not sin, Allah would replace us with a group of people that sin then ask for forgiveness and be forgiven:
عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ ﷺ: وَالَّذِي نَفْسِي بِيَدِهِ لَوْ لَمْ تُذْنِبُوا لَذَهَبَ اللَّهُ بِكُمْ وَلَجَاءَ بِقَوْمٍ يُذْنِبُونَ فَيَسْتَغْفِرُونَ اللَّهَ فَيَغْفِرُ لَهُمْ
Abu Huraira reported Allah's Messenger ﷺ having said: By Him in Whose Hand is my life, if you were not to commit sin, Allah would sweep you out of existence and He would replace (you by) those people who would commit sin and seek forgiveness from Allah, and He would have pardoned them.
Sahih Muslim 2749
Following sins with good deeds will have the reverse effect of what you are worried about: the good deeds will erase the sins as the Prophet ﷺ has informed us:
عن أبي ذر جندب بن جنادة، وأبي عبد الرحمن معاذ بن جبل، رضي الله عنهما، عن رسول الله ﷺ قال: اتق الله حيثما كنت واتبع السيئة الحسنة تمحها، وخالق الناس بخلق حسن
Abu Dharr and Mu'adh bin Jabal (May Allah be pleased with them)
reported that: Messenger of Allah (ﷺ) said, "Fear Allah wherever you
are, do good deeds after doing bad ones, the former will wipe out the
latter, and behave decently towards people".
Riyad as-Salihin » Hadith
Prayers, at any time in general, and at both start and end of the day and during the night in specific, also erase sins, as well as act as a deterrent of sinning:
وَأَقِمِ الصَّلَاةَ طَرَفَيِ النَّهَارِ وَزُلَفًا مِّنَ اللَّيْلِ ۚ إِنَّ الْحَسَنَاتِ يُذْهِبْنَ السَّيِّئَاتِ ۚ ذَٰلِكَ ذِكْرَىٰ لِلذَّاكِرِينَ
And establish prayer at the two ends of the day and at the approach of
the night. Indeed, good deeds do away with misdeeds. That is a
reminder for those who remember.
Finally, only disbelievers despair of Allah's mercy. As Muslims, we believe that Allah forgives all sins, regardless of how huge the amount of sins one would have long as shirk is not committed.