I was reading about the rights of the husband and wife and I came across this for the husband

Displeasure of the Husband
Holy Prophet (s.a.w.a.) said:

“If a woman hurts her husband through her tongue, Allah shall not accept even gold and silver from her nor any of her good deeds until she pleases her husband.”

Hazrat Imam Ja’far Sadiq (a.s.) said:

“If a woman spends a night in a state that her husband is displeased with her, Allah shall not accept her prayers until her husband is pleased with her and if a woman applies perfume for anyone other than her husband, Allah will not accept her prayers till she does not perform ablution like the obligatory ablution.”

Stepping out of the house without the Husband’s Permission
Hazrat Imam Muhammad Baqir (a.s.) narrates that a woman came to the holy presence of the Messenger of Allah (s.a.w.a.) and asked for the rights of a husband over his wife.

His eminence (s.a.w.a.) replied:

“Obey him, not to disobey him, not give anything from his house as charity without his permission, not even keep recommended fasts without his permission and submit to him. She should not step out of the house without his consent. If she steps out of the house without his consent of her husband, then all the angels of the heavens and the earth, the angels of Allah’s wrath as well as His Mercy, they curse her till she doesn’t return home.” 14

When reading this it feels as though women are slaves to their husbands, what if the man is cruel and unjust? It seems like our good deeds rely on the whims of men and it feels unfair. Is there a context to this?

A woman’s deeds are between her and Allah, the husband has no role or influence on this. What Islam emphasizes is the proper treatment of both the spouses to each other. A certain amount of emphasis is given to the husband, as you point out in the Hadith, due to the fact that he is the wali and the responsibility of maintenance, which he will be asked about strictly, is upon him. Even then, women are not the slaves of men, and a man is not the intercessor of his wife.