You will never see this just by reading Kings, but Jehoshaphat was a good king – at least, by most standards – meriting three chapters of coverage in the Chronicles. God was with him and granted him wealth and power.
So much power in fact that peace was effected between Israel and Judah. No one would dare challenge him.
Unfortunately, Jehoshaphat allied himself with the northern kingdom. On two separate occasions, he quite unwisely joins his army to that of Israel (compare 1 Kings 22:4-7 and 2 Kings 3:7 – 11). Likely for purely political reasons (though it is difficult to fathom why he needed to do this) he married his son, Jehoram, to Athaliah, the daughter of Ahab and sister of Joram (Ahab’s son and successor). He also made his son co-regent with him near the end of his reign (2 Kings 817ff).
Athaliah and Jehoram had a son, Ahaziah, who was killed by Jehu. Athaliah then sought to consolidate the northern and southern kingdoms by killing off all of her husband’s family (including her infant grandson, Joash) – but she was foiled by Jehosheba and her High Priest husband Jehoiada.
This event is of incredible importance. Had it not been for the leadership of this priest and his devotion to the Lord, the Davidic line would have ended – along with the kingship of Judah. It is interesting that God is not said to have taken an active hand in all this, but his providence is throughout the story.