إِذْ تُصْعِدُونَ وَلَا تَلْوُۥنَ عَلَىٰٓ أَحَدٍ وَٱلرَّسُولُ يَدْعُوكُمْ فِىٓ أُخْرَىٰكُمْ فَأَثَـٰبَكُمْ غَمًّۢا بِغَمٍّ لِّكَيْلَا تَحْزَنُوا۟ عَلَىٰ مَا فَاتَكُمْ وَلَا مَآ أَصَـٰبَكُمْ ۗ وَٱللَّهُ خَبِيرٌۢ بِمَا تَعْمَلُونَ
Asad Quran Translation
[Remember the time] when you fled, paying no heed to anyone, while at your rear the Apostle was calling out to you - wherefore He requited you with woe in return for [the Apostle's] woe, so that you should not grieve [merely] over what had escaped you, nor over what had befallen you: for God is aware of all that you do.111
I.e., the realization of how shamefully they had behaved at Uhud (see note  above) would be, in the end, more painful to them than the loss of victory and the death of so many of their comrades: and this is the meaning of the "test" mentioned in the preceding verse.
Malik Quran Translation
Remember how you fled in panic and did not even look back at one another while the Rasool, at your rear, was calling out to you! Consequently, Allah inflicted upon you one sorrow after another to teach you a lesson: not to grieve for what you lose nor at any misfortune you may encounter. Allah is well aware of all that you do.
Yusuf Ali Quran Translation
Behold! ye were climbing up the high ground without even casting a side glance at anyone and the Apostle in your rear was calling you back. There did Allah give you one distress after another by way of requital to teach you not to grieve for (the booty) that had escaped you and for (the ill) that had befallen you. For Allah is well aware of all that ye do. 464
It would seem that a party of horsemen led by the dashing Khalid ibn Al-walid came through the gap in the passes where the Muslim archers should have been, and in the confusion that arose, the retreating foe rallied and turned back on the Muslims. From the low ground on the bank of the valley the Muslims retreated in their turn and tried to gain the hill. They had a double loss: (1) they were baulked of the booty they had run after, and (2) their own lives and the lives of their whole army were in danger, and many lives were actually lost from their ranks. Their own lives being in danger, they had hardly time to grieve for the general calamity. But it steadied them, and some of them stood the test.
Mustafa Khattab Quran Translation
˹Remember˺ when you were running far away ˹in panic˺—not looking at anyone—while the Messenger was calling to you from behind! So Allah rewarded your disobedience with distress upon distress. Now, do not grieve over the victory you were denied or the injury you suffered. And Allah is All-Aware of what you do.
Piktal Quran Translation
When ye climbed (the hill) and paid no heed to anyone, while the messenger, in your rear, was calling you (to fight). Therefore He rewarded you grief for (his) grief, that (He might teach) you not to sorrow either for that which ye missed or for that which befell you. Allah is Informed of what ye do.
Ith tusAAidoona wala talwoona AAala ahadin waalrrasoolu yadAAookum fee okhrakum faathabakum ghamman bighammin likayla tahzanoo AAala ma fatakum wala ma asabakum waAllahu khabeerun bima taAAmaloona