IRS Pub 550 says under "Wash Sales", "More or less stock bought than sold," (pg. 56),
If the number of shares of substantially identical stock
or securities you buy within 30 days before or
after the sale is either more or less than the
number of shares you sold, you must determine
the particular shares to which the wash sale
rules apply. You do this by matching the shares
bought with an equal number of the shares
sold. Match the shares bought in the same order that you bought them, beginning with the first shares bought. The shares or securities so
matched are subject to the wash sale rules.
Under "Wash Sales", "Loss and gain on the same day," (pg. 57):
Loss from a
wash sale of one block of stock or securities
cannot be used to reduce any gains on identical
blocks sold the same day.
Example. During 2015, you bought 100
shares of X stock on each of three occasions.
You paid $158 per share for the first block of
100 shares, $100 per share for the second
block, and $95 per share for the third block. On
December 28, 2020, you sold 300 shares of X
stock for $125 per share. On January 11, 2021,
you bought 250 shares of identical X stock. You
cannot deduct the loss of $33 per share on the
first block because within 30 days after the date
of sale you bought 250 identical shares of X
stock. In addition, you cannot reduce the gain
realized on the sale of the second and third
blocks of stock by this loss.
Therefore, if you sold all 200 shares on February 1, 2023, and vested into 8 RSUs on February 20th, 2023, the loss on 8 shares ($50/share * 8 shares = $400) is disallowed.
You realize a gain of $5,000 (the 2019 shares), realize a loss of $4,600 (92 of the 2022 shares), and the $400 disallowed loss is added to the basis of the 8 newly-vested shares ($100/share + $50/share = $150/share basis). You have a net gain from the February 1, 2023 sale of $400.
This only holds true with your exact example provided, in a vacuum, with no other confounding variables. If you have any questions about how to treat your transactions, speak with a CPA, EA, or tax attorney.
Final note: it doesn't matter if the shares are in the same brokerage account or different ones. In fact, you can even trigger a wash sale if you sold shares in a taxable account at a loss and rebought the shares in an IRA within 30 days.