The speaker has lost both the beloved and the woman to each other, but consoles himself that their union is not his loss because the beloved and he are one—so really, the woman merely loves the beloved, who is the speaker.
Lines 1–4 distinguish two levels of grief. The beloved having the woman is not 'all' the speaker's sorrow; worse is that she has taken the beloved. Lines 3–4 claim that 'That she hath thee is of my wailing chief / A loss in love that touches me more nearly.' The loss of the beloved to another is more intimate than the loss of the woman herself. This is a crucial acknowledgment: the speaker's devotion to the beloved supersedes his romantic love for the woman. The real wound is not being supplanted in the woman's affections but losing the beloved's exclusive attention. The sonnet's emotional architecture reveals the hierarchy of the speaker's attachments: the beloved is primary, the woman secondary. This makes the betrayal doubly cruel: it's not just infidelity but usurpation of the beloved's allegiance.
Lines 9–14 attempt to transform this tragedy through sophistic reasoning. Lines 9–10 are nearly incomprehensible, but the logic seems to be: if losing the beloved means gaining the woman's favor (my loss = her gain), and the beloved gains from that favor, then losing the beloved means the beloved gains. Lines 11–12 then acknowledge the reality: 'Both find each other, and I lose both twain.' The speaker stands alone. Yet line 13 performs a final, astonishing reversal: 'But here's the joy, my friend and I are one.' This is explicitly labeled 'sweet flattery' (line 14), an acknowledged illusion. Because the beloved and speaker share an 'undivided love' (as stated in 36), their identities are fused. Therefore, the woman's love for the beloved is love for the speaker by extension. It is magical thinking, but it is also the only consolation available. The speaker cannot face the reality of loss, so he dissolves the boundaries of identity itself to preserve the fantasy of union.
Your best friend takes the person you love. You're devastated. But then you think: wait, I love him so much that we're basically the same person. So when she loves him, she's loving me through him. When they're together, it's like I'm there. It's comforting but also delusional. It's what you tell yourself when reality is unbearable.