Bug: A contact moved between address books become inaccessible with contacts.get() when it is operated via the "Edit Contact" popup on the header bar of the message pane
Status: NEW
Priority: --
Created: 2021-11-25 02:20:05+00:00
Resolved: 2022-10-28 19:08:32+00:00

# Steps to reproduce

1. Start Thunderbird.
2. Prepare a new address book.
   1. Click the "Address Book" toolbar button to show address books.
   2. Click the "New Address Book" button.
   3. Input arbitrary name , ex. "New AB".
3. Load the attached testcase as a temporary add-on and open the debugger for it.
   1. App menu => Tools => Developer Tools => Debug Add-ons
   2. Click "Load Temporary Add-on..." button and choose the testacase file.
   3. Click the "Inspect" button of the loaded testcase.
   4. Choose the "Console" tab.
4. Prepare a message with a recipient which is not stored in any address books.
   1. Switch back to a folder view tab.
   2. Click the "Write" button to start message composition.
   3. Input a recipient with an e-mail address never stored in any addressbooks, ex. "unknown@example.com"
   4. Click the "Save" button to save it as a draft.
   5. Close the compositon window.
5. Add a new contact via the header bar of the message pane.
   1. Switch back to a folder view tab.
   2. Go to the "Drafts" folder and choose the message you saved at the previous step.
   3. In the header bar of the message pane, you'll see a recipient "unknown@example.com" with a blank star. So click the star button.
   4. The star changes to blue. The console in the debugger console reports a new contact, like as: `created:  
Object { id: "e4ca5c4f-f812-4706-9e7b-0da9c212129b", parentId: "7b32c9a6-bc43-4f27-bc4c-088626388fec", ...`
6. Move the contact to another address book via the header bar of the message pane.
   1. Click the blue star of the recipient "unknown@example.com" again.
   2. "Edit Contact" popup appears, so choose "New AB" from the dropdown list.
   3. Click the "Done" button.
   4. The console in the debugger console reports two messages like as:
      * `created:  
Object { id: "e4ca5c4f-f812-4706-9e7b-0da9c212129b", parentId: "b9317058-7c83-42be-af87-3c355a8b06ab",...`
      * `deleted:  
Object { parentId: "7b32c9a6-bc43-4f27-bc4c-088626388fec", id: "e4ca5c4f-f812-4706-9e7b-0da9c212129b" }`
7. Try to access the moved contact with the API `browser.contacts.get()`.
   1. Call the API with the ID of the contact you moved, like: `browser.contacts.get('e4ca5c4f-f812-4706-9e7b-0da9c212129b').then(console.log)` (*Please note that the ID must be same to the one reported at the previous step.)
8. Remove the contact from the address book.
   1. Click the blue star of the recipient "unknown@example.com" again.
   2. "Edit Contact" popup appears, so click the "Delete" button.
   3. Click the "OK" button in the confirmation dialog.
9. Repeat the steps from 6 to 8 multiple times.

# Expected result

On every tries the got contact is reported like as: `Object { id: "e4ca5c4f-f812-4706-9e7b-0da9c212129b", parentId: "b9317058-7c83-42be-af87-3c355a8b06ab",...`

# Actual result

Sometimes an error is reported: `Error: contact with id=e4ca5c4f-f812-4706-9e7b-0da9c212129b could not be found.` (On my case the error appars on tries second and later.)

# Environment

* Windows 10 21H1 (64bit)
* Daily 96.0a1 (build ID: 20211124104918) with a new profile and an existing profile
* Thunderbird 91.3.2 (build ID: 20211117150618) with a new profile