The descendants of Jehoiachin were cursed in Jeremiah 22:
Yet, Matthew 1:28 Is this man Jehoiachin a despised, broken pot, an object no one wants? ...
30 This is what the LORD says: “Record this man as if childless, a man who will not prosper in his lifetime, for none of his offspring will prosper, none will sit on the throne of David or rule anymore in Judah.”
Joseph could not have sat on the throne of David because he was a biological descendant of Jehoiachin.11 and Josiah the father of Jeconiah [i.e., Jehoiachin] and his brothers at the time of the exile to Babylon. 12 After the exile to Babylon: Jeconiah was the father of Shealtiel, ...
15 Elihud the father of Eleazar, Eleazar the father of Matthan, Matthan the father of Jacob, 16 and Jacob the father of Joseph,
Here, Matthew did not say that Jesus was a son of Joseph. In fact, Jesus was a legal son of Joseph and not a biological descendant of Jehoiachin. Jesus was immune from the curse in Jeremiah 22:30.the husband of Mary, and Mary was the mother of Jesus who is called the Messiah.