How to Combine Maghrib and `Isha’ Prayers when Travelling
Question

I was travelling and I wanted to join Maghrib and `Isha’ together. I reached the area where I live at the time of `Isha’, so I prayed `Isha’ with them, then I prayed Maghrib. Is what I did correct or not?
What are the conditions for putting prayers together when travelling?
Praise be to Allah.Conditions of combining prayers when travelling
It is permissible for the traveller to put prayers together according to the following conditions:
·         The distance [of his journey] should be the distance at which it becomes permissible to shorten prayers , which is approximately 80 km according to the majority of scholars. Some of the scholars are of the view that the distance that counts as travel is not defined by a specific distance; rather it is the matter of custom [and what is customarily regarded as travel].
·         According to the majority of scholars, it is stipulated that the travel should be for a permissible purpose. So if someone travels in order to rob people (banditry) or to commit immoral actions or other sins, it is not permissible for him to avail himself of the concession of the traveller. However, that was not stipulated by Abu Hanifah (may Allah have mercy on him). See:  Al-Mawsu`ah Al-Fiqhiyyah (27/276).
·         He should intend to stay for four days or less. If he intends to stay for longer than that, he cannot avail himself of the concessions of travel, such as not fasting in Ramadan and shortening prayers and putting them together.
The scholars of the Permanent Committee for Ifta’ said:
If he intends to stay for more than four days, then it is not permissible for him to avail himself of the concessions of travel, such as joining prayers together and shortening them, and the like. But if he intends to stay for four days or less than four days, or his journey depends on completing his errands, so when he has completed his errands he will leave, and he has not already decided on the length of stay that would allow him to avail himself of the concessions of travel, then it is permissible for him to avail himself of the concessions of travel."(Fatawa Al-Lajnah Ad-Da’imah  8/113-114)
·         He should not begin to avail himself of the concessions of travel until he has left his city. 
See: Al-Mawsu`ah Al-Fiqhiyyah (27/279).
·         The majority of scholars stipulated that he should do the two prayers consecutively when he joins them together at the time of the earlier prayer, so he should not leave a long gap between the two prayers.
Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) favoured the view that that is not a condition. See: Majmu` Al-Fatawa (24/54).
·         It is stipulated that the two prayers that are joined together should be done in the correct order. This is the view of the majority.
The scholars of the Permanent Committee for Ifta’ said: 
“When joining prayers together , it is obligatory to do them in the correct order, so that [the traveller] prays Thuhr first, then prays `Asr , and he prays Maghrib first, then prays `Isha’ , whether he is joining them together at the time of the earlier or later prayer." (Fatawa Al-Lajnah Ad-Da’imah  8/139)
How to combine Maghrib and `Isha; prayer when travelling
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said:
“It is stipulated that the prayers be done in the correct order, starting with the first one and then the second, because the Prophet (blessings and peace of Allah be upon him) said: “Pray as you have seen me pray.” And because Islamic teachings have explained the order of the times of prayer. But if the person forgets, or is unaware of the ruling, or comes to some people who are praying `Isha’, and he intended to put the prayers together at the time of the later prayer, then he prays `Isha’ with them, then he prays Maghrib, is the requirement to offer the prayers in the correct order waived in this case, or not?
The most well-known view among our jurists (may Allah have mercy on them) is that it is not waived. Based on that, if someone did the second prayer before the first prayer by mistake, or out of ignorance, or to join the congregation, or for other reasons, then his joining the prayers together is not valid. So what must he do in this case?
The answer is: the prayer that he offered first is not valid as an obligatory prayer, and he has to repeat it.
For example: a man was intending to join the prayers together at the time of the later prayer, then he entered the mosque and found some people praying `Isha’, so he joined them with the intention of praying `Isha’, then when he had finished `Isha’ he prayed Maghrib. We say: His `Isha’ prayer is not valid, because he offered it before Maghrib, and offering the prayers in the correct order is a condition [of prayer being valid]. So he has to pray `Isha’ again, but his Maghrib is valid. When we say that it is not valid, we mean that it is not valid as an obligatory prayer that would fulfil the obligation, but it is regarded as a supererogatory prayer for which he will be rewarded." (Ash-Sharh Al-Mumti` 4/401-402)
And Allah knows best.