You are referring to a special version of this sahih hadith (al-Bukahri, and a longer Version for example in Muslim) on the supplication/curse of an oppressed دعوة المظلوم. Note the addition of "even if he is a disbeliever" doesn't have enough support to be qualifeid as sahih, so it is in best case considered as a "hassan" hadith.
I think the longer Version which is also in sahih al-Bukahri, Jami' at-Tirmdihi, sunan abi Dawod, sunan an-Nasai, sunan ibn Majah. Gives a hint on how this is to be understood we should not oppress others as Allah hates the oppressor and oppression (see for example this hadith) as quoted in this hadith qodsi. If an oppressed person asks Allah doing supplication or cursing somebody then they will reach Allah, even if this person maybe a sinner or a non-believer (as stated clearly in the hadith in Musnad Ahmad on the authority of Anas " دعوة المظلوم وإن كان كافرا ليس دونها حجاب" which you -apparently- are referring to) or somebody who eats haram as stated in this hadith.
The -apparently contradicting- quote from 13:14 and 40:50 saying:
... And the supplication of the disbelievers is not but in error [i.e. futility].
is referring to the supplication of the non-believers asking Allah to not let them enter jahanam. It doesn't cover any other kind of supplication, which is perfectly permissible for them (see for example this hadith, where a Jewish woman made a supplication for 'Aisha).
On the importance and acceptance of the suplication of an oppressed see also this hadith which is in jami' at-Tirmdihi, sunan abi Dawod and sunan ibn Majah.
And Allah knows best!