Our Gemara on Amud Aleph leads with a well known dictum:

If one gives charity, saying: I give this sela for charity in order that my children may live, or: I give it in order that through it I may merit life in the World-to-Come, he is still considered a full-fledged righteous person. 

The Gemara also draws a distinction between a Gentile and A Jew:

⁦This only applies to a Jewish person. Because even if his condition is not fulfilled, he will not complain to God. However, A gentile may come to regret his actions and complain to God if his condition is not fulfilled, and therefore is not permitted to make conditions with God.

A couple of observations regarding this Gemara:

Tosafos raises a contradiction between this Gemara and the Mishna Avos (1:3) that one should serve God as a faithful servant who acts out of love and loyalty, without any expectation of reward. Tosafos answers that the Mishna in Avos is referring to Gentiles, who as our Gemara mentioned, are not capable of mixing motives without feeling resentful if the expected reward does not come.

Tosafos’ answer seems forced. Why would a Mishna in Avos offer ethical advice to Gentiles, especially without clarifying the target audience? Most likely, Tosafos was speaking euphemistically, and he meant to say, albeit indirectly, that even a Jewish person should not do a mitzvah with an expectation that he WILL ABSOLUTELY receive the desired reward. Yet, as our Gemara says, he can engage with motivations and hopes of a reward. (See Maharsha on Tosafos.)

This also brings us to a way of understanding a cryptic Rashi on this Gemara. He states:

הרי זה צדיק גמור - אם רגיל בכך:

He is a full-fledged righteous person, if he is accustomed to do so

We must ask, “Accustomed to do what?” If Rashi meant accustomed to always making conditions when performing mitzvos, you would have to understand Rashi as meaning EVEN if he is accustomed to doing so, he still is righteous. Since Rashi doesn’t say “even”, I am inclined to interpret Rashi as follows:  If he is accustomed to give charity often, then he is still fully righteous if one time he has in mind a condition or merit that he is hoping to achieve. This interpretation then is similar to Tosafos, in that the main thrust is that there not be a set up for disappointment and regret if his expected reward does not come about. If one is in the habit of giving charity anyhow, it shows the main motivation is altruistic.

One more interesting point. It seems the Derech Chaim on Avos slightly disagrees with Rashi and Tosafos. He says, the phrase “ ״צדיק גמור - “full-fledged righteous person” does not mean to say, “exceptionally righteous or exemplary” Rather it means to say, “Fully righteous in a sense that there is no deficiency”, but not that it is the highest level. 

He is understanding the word Tzaddik as it is used often in Tanach Hebrew, not vernacular Hebrew. That is, Tzaddik means simply not guilty of wrongdoing and in comparison to a רשע , an evil-doer, as opposed to a Chasid, who is exemplary. In Tanach Hebrew, often the word Tzaddik is better translated as “not guilty, innocent or free of wrongdoing.” See for example: Bereishis (18:23) “⁦Abraham came forward and said, “Will You sweep away the innocent along with the guilty?” , or Devarim (25:1) “⁦When there is a dispute between men and they go to law, and a decision is rendered declaring the one in the innocent and the other who is guilty.”

Knowing Hebrew as it’s intended in Tanach by learning its meanings through Tanach makes a subtle difference in how words are translated. For example, in reference to Noach, the pashut peshat is indeed that he was innocent enough that he should not be implicated in his generation’s wrong doing. Thus Bereishis (7:1) translates best as: “⁦Then the LORD said to Noah, “Go into the ark, with all your household, for you alone have I found innocent before Me in this generation.”, Not, “found you to be righteous.” Similarly, Avimelech is not claiming that he is a pious man, he simply is claiming that he is innocent. Bereishis (20:4) “⁦Now Abimelech had not approached her. He said, “O Lord, will You slay people even though innocent?” Likewise, in the verse we saw earlier, Avraham was not looking for pious people in Sodom, just people that were not wickedly guilty.