Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:3:156

O you who have believed, do not be like those who disbelieved and said about their brothers when they traveled through the land or went out to fight, "If they had been with us, they would not have died or have been killed," so Allah makes that ˹misconception˺ a regret within their hearts. And it is Allah who gives life and causes death, and Allah is Seeing of what you do.  

O you who believe, be not as the disbelievers, that is, ˹as˺ the hypocrites, who say of their brothers, that is, regarding their affair, when they travel in the land, and then die, or are on raiding campaigns (ghuzzan, ‘a raiding party’, is the plural of ghāzin), and are then slain, ‘Had they been with us, they would not have died and would not have been slain’, in other words, do not say as they say — so that God may make that, saying ˹of theirs˺, as a conclusion of their affair, anguish in their hearts. For God gives life, and He gives death, and so no staying put can prevent death, and God sees what you do (ta‘malūna, or ya‘malūna, ‘they do’), and He will requite you for it.
القرآن:٣:١٥٦

يَا أَيُّهَا الَّذِينَ آمَنُوا لَا تَكُونُوا كَالَّذِينَ كَفَرُوا وَقَالُوا لِإِخْوَانِهِمْ إِذَا ضَرَبُوا فِي الْأَرْضِ أَوْ كَانُوا غُزًّى لَوْ كَانُوا عِنْدَنَا مَا مَاتُوا وَمَا قُتِلُوا لِيَجْعَلَ اللَّهُ ذَٰلِكَ حَسْرَةً فِي قُلُوبِهِمْ ۗ وَاللَّهُ يُحْيِي وَيُمِيتُ ۗ وَاللَّهُ بِمَا تَعْمَلُونَ بَصِيرٌ  

{يا أيها الذين آمنوا لا تكونوا كالذين كفروا} أي المنافقين {وقالوا لإخوانهم} أي في شأنهم {إذا ضربوا} سافروا {في الأرض} فماتوا {أو كانوا غُزٌى} جمع غاز فقتلوا {لو كانوا عندنا ما ماتوا وما قتلوا} أي لا تقولوا كقولهم {ليجعل الله ذلك} القول في عاقبة أمرهم {حسرة في قلوبهم والله يحيي ويميت} فلا يمنع عن الموت قعود {والله بما تعملون} بالتاء والياء {بصير} فيجازيكم به.