Get your taxes done using TurboTax

Can I sell the SIS with the high adjusted cost base in the same year?
In other words

For example,
(1) I sell stock A for a $100 loss. (I held A for years)
(2) A week after, I vest more RSUs of A and (3) immediately sell at the same price I bought it. Because of the adjusted cost base, the second sale has an adjusted loss of $100.
(4) Then I sell an unrelated stock 'B' at a gain of $100.
Overall the net gain/loss is $0.

Can all this happen in the same year?