This is a brilliant testimony of God rescuing His people.
Jehoshaphat was king of Judah at the time of this chapter, and he rightly sought God’s help during this time of threat-of-attack from hostile forces.
However this king of Judah (Jehoshaphat) also did bad things. In particular, he joined himself to wicked kings of Israel both before and after God’s rescue of him and his people.
• with king Ahab (in chapter 18), prior to God’s rescue in chapter 20.
• and with king Ahaziah, (in chapter 20, verses 35-37), following God’s rescue.