Q. Why is Ruth called the Moaviah, and the Talmud Yebamos discusses whether she and King David, her offspring were permitted to intermarry with the Jewish nation. Rashi explains at the beginning of Megilas Ruth that she was the daughter of King Eglon, the son of Balak. And as Rashi explains at the beginning of Parshas Balak, he was from Midyan and permitted to convert and marry. So Ruth was not Ruth Hamoaviah, rather she was Ruth the Midyonite?

A. Several Meforshim deal with this question. Maharit (Kidushin 67a) explains that at the time the Torah decreed that Moabites should be prohibited; “Because they did not greet you with bread and water on the way, when you left Egypt, and because he [the people of Moab] hired Bilaam the son of Beor from Pessor in Aram Naharaim against you, to curse you.” (Devarim 23: 5), it also included Balak although he was a Midyonite, and all his descendants, as he was the initiator of the wrong committed against the Jewish Nation.
Horav Shlomo Miller’s Shlit”a opinion is that even though it is mentioned that Eglon was the son of Balak, it is common to address a descendant after many generations still as a son or daughter. It is likely that one of the forefathers of Eglon, in the many generations that transpired from Balak, was the son of a female offspring of Balak who married a Moabite. (See Chidushei R”M Meimran, Ibid.)
Horav Yaakov Hirschman Shlit”a quoted that despite that Rashi (Bamidbar 22: 4) citing Medresh Raba and Tanchuma, explains that Balak; “was not entitled to the monarchy, since he was one of the Midianite nobles… and they appointed him over them on a temporary basis,” he actually originated from Moab and then resettled in Midyan.

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a