Answer
✅Answer: The narrations do not provide a clear criterion for distinguishing this, but consider the following two narrations:
عَنْ أَبِی عَبْدِ اللّهِ علیه السلام، قَالَ: «قَالَ أَمِیرُ الْمُوءْمِنِینَ علیه السلام فِی قَوْلِ اللّهِ عَزَّ وَ جَلَّ: «وَ ما أَصابَکُمْ مِنْ مُصِیبَةٍ فَبِما کَسَبَتْ أَیْدِیکُمْ وَ یَعْفُوا عَنْ کَثِیرٍ» لَیْسَ مِنِ الْتِوَاءِ عِرْقٍ، وَ لاَ نَکْبَةِ حَجَرٍ، وَ لاَ عَثْرَةِ قَدَمٍ، وَ لاَ خَدْشِ عُودٍ إِلاَّ بِذَنْبٍ، وَ لَمَا یَعْفُو اللّهُ أَکْثَرُ؛ فَمَنْ عَجَّلَ اللّهُ عُقُوبَةَ ذَنْبِهِ فِی الدُّنْیَا، فَإِنَّ اللّهَ عَزَّ وَ جَلَّ أَجَلُّ وَ أَکْرَمُ وَ أَعْظَمُ مِنْ أَنْ یَعُودَ فِی عُقُوبَتِهِ فِی الاْآخِرَةِ
📚Al-Kafi, Vol. 2, p.445
Translation: Imam al-Sadiq (peace be upon him) said: Regarding the statement of Allah, the Exalted, 'And whatever calamity befalls you is because of the deeds of your own hands; and Allah pardons much,' Amir al-Mu'minin (peace be upon him) said: No twisted vein, clash with a stone, slipping of a step, or scratch of wood occurs except due to sin, and that which Allah pardons is far greater. So whoever Allah hastens the punishment of their sin in this world, Allah, Exalted, is too great and magnificent to punish them for it in the Hereafter.
عَنْ عَلِیِّ بْنِ رِئَابٍ، قَالَ:
سَأَلْتُ أَبَا عَبْدِ اللّهِ علیه السلام عَنْ قَوْلِ اللّهِ عَزَّ وَ جَلَّ: «وَ ما أَصابَکُمْ مِنْ مُصِیبَةٍ فَبِما کَسَبَتْ أَیْدِیکُمْ» أَرَأَیْتَ مَا أَصَابَ عَلِیّاً علیه السلام وَ أَهْلَ بَیْتِهِ علیهم السلام مِنْ بَعْدِهِ هُوَ بِمَا کَسَبَتْ أَیْدِیهِمْ وَ هُمْ أَهْلُ بَیْتِ طَهَارَةٍ مَعْصُومُونَ؟
فَقَالَ: «إِنَّ رَسُولَ اللّهِ صلی الله علیه و آله کَانَ یَتُوبُ إِلَی اللّهِ وَ یَسْتَغْفِرُهُ فِی کُلِّ یَوْمٍ وَ لَیْلَةٍ مِائَةَ مَرَّةٍ مِنْ غَیْرِ ذَنْبٍ، إِنَّ اللّهَ یَخُصُّ أَوْلِیَاءَهُ بِالْمَصَائِبِ لِیَأْجُرَهُمْ عَلَیْهَا مِنْ غَیْرِ ذَنْبٍ
📚Al-Kafi, Vol. 2, p.450
Translation: Ali ibn Ri'ab said: I asked Imam al-Sadiq (peace be upon him) about the verse 'And whatever befalls you is because of your deeds.' Tell me, what befell Ali (peace be upon him) and his family after him—was it due to their deeds or sins while they are people of purity and infallible? The Imam said: Indeed, the Messenger of Allah (peace be upon him and his family), without having any sin, would repent to Allah a hundred times daily and seek forgiveness from Allah. Indeed, Allah bestows calamities upon His friends and chosen ones to reward them for that calamity without them having committed any sin.
✅What is established from the hadiths is that the Messenger of Allah (peace be upon him and his family) and the Ahl al-Bayt (peace be upon them), who are all infallible, experience all their calamities for reward and elevation of rank. But calamities that befall people like us, according to the first narration, are mostly due to our sins, while those that are for reward and elevation of rank are not clearly identifiable. Consider the following narrations as well:
عَنْ أَمِیرِ الْمُؤْمِنِینَ قَالَ: مَا مِنَ الشِّیعَةِ عَبْدٌ یُقَارِفُ أَمْراً نَهَیْنَاهُ عَنْهُ فَیَمُوتُ حَتَّی یُبْتَلَی بِبَلِیَّةٍ تُمَحَّصُ بِهَا ذُنُوبُهُ إِمَّا فِی مَالٍ وَ إِمَّا فِی وَلَدٍ وَ إِمَّا فِی نَفْسِهِ حَتَّی یَلْقَی اللَّهَ عَزَّ وَ جَلَّ وَ مَا لَهُ ذَنْبٌ وَ إِنَّهُ لَیَبْقَی عَلَیْهِ الشَّیْ ءُ مِنْ ذُنُوبِهِ فَیُشَدَّدُ بِهِ عَلَیْهِ عِنْدَ مَوْتِهِ.
📚Bihar al-Anwar, Vol. 6, p.157
Translation: Amir al-Mu'minin (peace be upon him) said: No servant from among our Shi‘ah commits an act that we have forbidden, except that before dying they are afflicted in wealth, children, or life so that their sins are purified, and some sins remain that will be exacted upon at the time of death.
In the narration in 📚Kitab 'Uddat al-Da‘i, Imam al-Sadiq (peace be upon him) said: Disease for a believer is purification and mercy, and for a disbeliever it is punishment and curse. Illness always accompanies a believer until no sin remains upon them.
In the narration in 📚Al-Kafi, Vol. 3, p.218, Imam al-Sadiq (peace be upon him) said: Indeed, Allah, Exalted, selects the most valuable of a believer’s wealth and children (and takes it) so that He may reward them for it.