Altering commerce invoice mails fails I'm altering different emails from my hook_mail_alter(&amp;$message) function. But for some reason altering the email sent by commerce invoice module is not working. I'm trying to do it like:
switch($message['id']){
    case 'invoice_confirmation':
      $message['subject'] = 'Some other title';
      break;

I found the code that sends that email in invoice module:
  public function send(InvoiceInterface $invoice, $to = NULL, $bcc = NULL) {
    $to = isset($to) ? $to : $invoice-&gt;getEmail();
    if (!$to) {
      // The email should not be empty.
      return FALSE;
    }

    $subject = $this-&gt;t('Invoice #@number', ['@number' =&gt; $invoice-&gt;getInvoiceNumber()]);
    $body = [
      '#theme' =&gt; 'commerce_invoice_confirmation',
      '#invoice_entity' =&gt; $invoice,
      '#totals' =&gt; $this-&gt;invoiceTotalSummary-&gt;buildTotals($invoice),
    ];
    if ($billing_profile = $invoice-&gt;getBillingProfile()) {
      $body['#billing_information'] = $this-&gt;profileViewBuilder-&gt;view($billing_profile);
    }

    $params = [
      'id' =&gt; 'invoice_confirmation',
      'from' =&gt; $invoice-&gt;getStore()-&gt;getEmail(),
      'bcc' =&gt; $bcc,
      'invoice' =&gt; $invoice,
    ];
    $customer = $invoice-&gt;getCustomer();
    if ($customer-&gt;isAuthenticated()) {
      $params['langcode'] = $customer-&gt;getPreferredLangcode();
    }
    $file = $this-&gt;invoiceFileManager-&gt;getInvoiceFile($invoice);
    $attachment = [
      'filepath' =&gt; $file-&gt;getFileUri(),
      'filename' =&gt; $file-&gt;getFilename(),
      'filemime' =&gt; $file-&gt;getMimeType(),
    ];
    $params['attachments'][] = $attachment;

    return $this-&gt;mailHandler-&gt;sendMail($to, $subject, $body, $params);
  }

}

and there I saw that id should be 'invoice_confirmation', but like my hook function is never reached when this email is sent?! How to alter this email title?
Solved the issue - id is actually 'commerce_invoice_confirmation'.
I was trying to print out $message['id'] and stop executing of code, but that never happened? So I assumed that my code was never called. Not sure why. So I used watchdog logger to log id value and found it out.