If you buy (or sell) a substantially identical security after realizing a loss, it's a wash sale. It doesn't matter what happens subsequently to your option (assignment, exercise or expiry). It is or it isn't.
If it is a wash sale, it's not a problem if all involved positions are closed by the end of the year. It becomes an accounting issue if a wash sale is carried over into the new tax year.
The real question is, is it a wash sale? That's where the answer gets murky.
From Fairmark.com:
Selling Put Options
You can also turn a sale of stock into a wash sale by selling put options. This rule is not automatic. It applies only if the put option is deep in the money — and there’s no precise standard as to when a put option is deep enough in the money for the rule to apply. The rule applies if it appears, at the time you sell the put option, that there is no substantial likelihood it will expire unexercised. In this circumstance, selling the put option can be roughly equivalent to buying the stock.
And from the NASDAQ:
SELL STOCK, SELL PUT
Lastly, clients can sell their stock for a loss and then sell a put option on those shares.
Example: Mary buys XYZ stock at $50; it is now at $35. Mary sells at $35, realizing a $15 loss. Mary then sells a 31-day put, allowing the buyer to put that stock back to Mary at $40 a share. If the stock stays below $40, Mary gets her shares back. Is this a wash sale?
In a put sale, the government will declare a wash sale when the put position is substantially identical to the stock – that is, when there is a high likelihood that the put will be exercised (unlike the call purchase rule that damns any call purchase).
Most tax practitioners would have no issue if Mary sells an out-of-the-money put, a slight caution if Mary sells an at-the-money put and a genuine concern if the put is in-the-money, with concern growing as the put gets deeper and deeper in the money.