Allah tells us that Musa and his companion Al-Khidr set out having come to an agreement and reached an understanding. Al-Khidr had made the condition that Musa should not ask him about anything he found distasteful until he himself initiated the discussion and offered an explanation. So they went on board the ship, as described in the Hadith quoted above -- the crew recognized Al-Khidr and let them ride on board free of charge, as an honor to Al-Khidr. When the boat took them out to sea and they were far from the shore, Al-Khidr got up and damaged the boat, pulling out one of its planks and then patching it up again. Musa, peace be upon him, could not restrain himself from denouncing him, so he said:
It was said in verse 71: أَخَرَقْتَهَا لِتُغْرِقَ أَهْلَهَا (Did you break it that you drown its people?). About it, it appears in the Hadith of the Sahihs of al-Bukhari and Muslim that al-Khadir (علیہ السلام) had dislodged a plank of the
boat with an axe because of which there was a danger that water would fill up the boat and it would capsize. Therefore, Sayyidna Musa (علیہ السلام) had objected to it. But, according to historical reports, water did not fill into this boat. This may have happened either because al-Khadir had somehow repaired it himself soon after - as in a report carried by al-Baghawi according to which al-Khadir (علیہ السلام) had replaced the plank with glass. Or, water just did not enter the boat in the manner of a miracle. However, the context of the Qur’ an by itself is telling us that the boat did not capsize - something which supports these reports.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 70–73
Moses was told about a further sign, i.e. that when he reached the required destination, the fish kept for eating would go down into the water in a peculiar manner. And at a certain place this was exactly what happened. But the fish was with the disciple and he could not for some reason inform Moses about this incident. After proceeding a little further, Moses came to know of this incident. He immediately returned to that place and found Khidr there, the person for whom he had undertaken such a long journey. God had bestowed on this servant, Khidr, special knowledge and powers, so that he could bring certain extraordinary influence to bear upon the affairs of this world. In view of this knowledge, he used to act against the customary norms. That is why, on Moses request to be allowed to accompany him, he said that he Moses would not be able to bear it.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.