Jehoshaphat, son of Asa, is one of the good kings of Judah, but like all the good kings including David, he makes mistakes and is subject to warnings and judgment and the never-ending love of God.
In Chapter 18, Jehoshaphat makes an unholy alliance with Ahab, one of the most evil kings of Israel, in a sincere act of unity between the two halves of the badly divided kingdom of Israel. They go to war together and Ahab dies in the battle (his judgment from God has long since been cast in stone). Jehoshaphat survives and returns home in Chapter 19.
2 But Jehu the son of Hanani the seer went out to meet him and said to King Jehoshaphat, “Should you help the wicked and love those who hate the Lord? Because of this, wrath has gone out against you from the Lord. 3 Nevertheless, some good is found in you, for you destroyed the Asheroth out of the land, and have set your heart to seek God.” 
Note carefully here: the perfect unity Jesus prayed for was to be among his disciples and those who would eventually believe in Jesus as Savior and Lord through the foundational ministries of the disciples. It was not the disunity of unholy alliance with wicked members of the family of God who blatantly hate the Lord! The fruits of disunity are judgment, straight from God.
Jehoshaphat gets the message clearly and exhibits sincere repentance. He goes out among all the people of Judah and brings them back to God. Further, he appoints judges throughout the land to make sure that the Lord is part of all decisions made throughout the country and tells them:
“Consider what you do, for you judge not for man but for the Lord. He is with you in giving judgment. 7 Now then, let the fear of the Lord be upon you. Be careful what you do, for there is no injustice with the Lord our God, or partiality or taking bribes.” 
Jehoshaphat even creates a Supreme Court to judge disputed cases from the lower courts:
9 And he charged them: “Thus you shall do in the fear of the Lord, in faithfulness, and with your whole heart: 10 whenever a case comes to you from your brothers who live in their cities…you shall warn them, that they may not incur guilt before the Lord and wrath may not come upon you and your brothers.”
By stark comparison, America is busy removing God from our courts, including the Ten Commandments as a symbol of God. And judges increasingly “help the wicked and love those who hate the Lord.” Partiality has stripped the blindfold from the scales of justice. America teeters on the edge of a Godless Supreme Court and Circuit Courts.
Jehoshaphat was informed that God’s wrath would follow a turn away from God. He did the right thing, not only for himself but for all his people, showing true repentance.
Let the fear of the Lord be on us as we select judges, perhaps irrevocably. For there is no injustice with the Lord our God, or partiality or taking bribes.
 The Holy Bible: English Standard Version. (2001). (2 Ch 19:2–3). Wheaton: Standard Bible Society.
 The Holy Bible: English Standard Version. (2001). (2 Ch 19:6–7). Wheaton: Standard Bible Society.
 The Holy Bible: English Standard Version. (2001). (2 Ch 19:10). Wheaton: Standard Bible Society.