The anecdote sounds like a simplified version of a parable by the sixth Lubavitcher rebbe, R. Yosef Yitzchak Schneersohn. At a farbrengen in 1985, R. Menachem Mendel Schneerson, the succeeding rebbe, included the teaching in his talk (and appears in Sichos, vol. 27):
The Previous Rebbe told a parable of a coachman who was driving several scholars in his stagecoach. During the trip the scholars were discussing lofty intellectual concepts, and consequently there were three distinct “thoughts” on the trip: The horses were “thinking” of the hay that they would receive when they reach their destination, the coachman’s mind was occupied with the thought of the handsome fee he would collect for the trip, and the scholars were involved with their intellectual pursuits. “Now,” asks the Previous Rebbe, “just because the horse thinks of fodder does that change anything in the intellectual involvement of the scholars?”
Actually this parable could do with some further elucidation. There
really is some connection between the thoughts of the horse and the
sages. Being en route, their minds are not relaxed and sharp enough
for them to reach a decisive halachic conclusion. The Gemara says:
“Halachah needs a clear mind” (Eruvin 65a); while they are traveling
their minds are not clear.
If so, the horse’s mind is not so insignificant, for the scholars want to conclude their intellectual exercise with a conclusive ruling. This will only happen when they reach their destination, which depends on the horse, which runs along because it “thinks” of the hay that lies ahead! Thus the goal of the sages’ “thought” in the carriage depends on the goal of the horse’s “thought” while running. In this manner they will reach their destination, and make their ruling, which will lead to: “Study is greater for it leads to action” (Kiddushin 40b). And the action will reveal the G‑dly will, which will effect an abode for G‑d in the lower worlds!
Many folktales transform considerably over time as they are transmitted. The lesson you surmise from the short teaching contrasts from the hassidic teaching here, but they share the bare bones. If your anecdote derives from this parable, it's not hard to see how hay becomes oats, and how a relationship between the mind of a horse and Jewish scholars transforms into an equivalence between a horse and a notable German philosopher.