WCF 3.1 God, from all eternity, did—by the most wise and holy counsel of his own will—freely and unchangeably ordain whatever comes to pass. Yet he ordered all things in such a way that he is not the author of sin, nor does he force his creatures to act against their wills;
3.2 Although God knows whatever may or can come to pass under all conceivable conditions, yet he has not decreed anything because he foresaw it as future or as that which would come to pass under such conditions.
5.1. God—the great Creator of all things—upholds, directs, disposes, and governs all creatures, actions, and things, from the greatest even to the least. He exercises this most wise and holy providence according to his infallible foreknowledge and the free and unchangeable counsel of his own will, to the praise of the glory of his wisdom, power, justice, goodness, and mercy.
As we look at the life of Joseph, everything happens according to God’s plan.
This account in Genesis does not minimize the wrong that was done or excuse it.
Other Scripture: Genesis 37:18-20; 37:26-28; 42:21; 50:20