God would oppose anything that would blaspheme Him in anything Joseph did. Pharaoh’s will could never take precedence.
Not to mention it was the idea of the people themselves to sell themselves to Pharaoh (Gen. 47:19).
There is no question that Joseph traded sustenance in exchange for lands and cattle and other assets. Those assets became property of the Pharoah. That’s what he did, that’s not up for debate.
If you are going to claim that Joseph had clean hands in that, than you’d have to make the claim that it is God’s will for us to transfer our property to the government.
“You will own nothing and be happy.”
The most that Joseph could have done was ensure that any grain given for land and cattle was done with an even hand and nobody was shorted.
Sometimes, as Christians, that’s all we can do is make sure the law is enforced with as little harm to the person as possible.