The Mishnah on today’s daf (=page) asks this question, and although the Tanna Kamma (=first) rules that the animal is kosher, Rabbi Eliezer argues that the shehitah is not acceptable. His argument is that even if the non-Jew did plan to eat a small portion of the animal – indicating, apparently, that his intention was truly for food – nevertheless we suspect that the non-Jew intended that the animal be slaughtered on behalf of idolatry.
In response to Rabbi Eliezer’s ruling, the Mishnah brings the argument of Rabbi Yose who explains why the non-Jew’s thoughts could not affect the status of the animal. He points to the case of kodashim – of Temple sacrifices – where we find that inappropriate thoughts would affect the status of the animal being slaughtered, and yet only the thoughts of the person performing the service are significant; the thoughts of the owner standing on the side are not taken into account. It is therefore logical to conclude that in ordinary slaughter, where the thoughts of the participants are not usually significant, we certainly would not take into account the thoughts of the non-Jew who is not involved in the actual slaughter.
Rabbi Eliezer’s reasoning is that if we do take into account the intent of the owner of the animal, then the ritual slaughter effectively becomes tikrovet avodah zarah – a sacrificial offering to idolatry – from which a Jew cannot derive any benefit. According to the Gemara in Masechet Avodah Zarah (daf 29b) this is derived from the passage in Sefer Tehillim (106:28) that describes the behavior of the Israelites in the desert as people who “joined themselves unto Baal of Peor, and ate the sacrifices of the dead,” which is understood by the Sages as teaching that just as it is forbidden to derive benefit from the dead, similarly it is forbidden to derive benefit from idol worship.