jQuery selector keeps returning an empty string

I don’t know if it’s the [data-a-target="smc-detail-page-thank-you-summary-amount-collected-date"] jQuery selector that the browser doesn’t like, but I keep getting an empty string and fail to extract the date on this very trimmed and dumbed down piece of code that I copy-pasted in a “test.html” file:

<!DOCTYPE html>
<html>
<head>
<title>Extract Date</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
  let dateString = $('[data-a-target="smc-detail-page-thank-you-summary-amount-collected-date"] .expandable-text-wrapper').text();
  console.log(dateString);
});
</script>
</head>
<body>

<div class="tw-flex">
  <div class="row-layout__column-2 tw-mg-r-3">
    <div class="tw-mg-b-2 tw-overflow-hidden">
      <div class="tw-lg-mg-b-05">
        <p class="tw-amazon-ember tw-amazon-ember-regular tw-c-text-base tw-font-size-6 tw-regular" title="Collected on">Collected on</p>
      </div>
      <div data-a-target="BasicInfoChildren">
        <p class="claim-summary-expandable-text__body--collapsed tw-c-text-white tw-font-size-6 tw-md-font-size-5" data-a-target="smc-detail-page-thank-you-summary-amount-collected-date">
          <div tabindex="-1" class="expandable-text-wrapper">Jun 18, 2024</div>
        </p>
      </div>
    </div>
  </div>
  <div class="row-layout__column-2">
    <div class="tw-mg-b-2 tw-overflow-hidden">
      <div class="tw-lg-mg-b-05">
        <p class="tw-amazon-ember tw-amazon-ember-regular tw-c-text-base tw-font-size-6 tw-regular" title="Sent to">Sent to</p>
      </div>
      <div data-a-target="BasicInfoChildren">
        <p class="claim-summary-expandable-text__body--collapsed tw-c-text-white tw-font-size-6 tw-md-font-size-5" data-a-target="claim-summary-publisher-name">
          <div tabindex="-1" class="expandable-text-wrapper">Amazon Games library</div>
        </p>
      </div>
    </div>
  </div>
</div>

</body>
</html>

I even verified with Codeium and ChatGPT, asking them if my code was right and they both said it was fine.
I tried using this selector though: let dateString = $('.expandable-text-wrapper').text(); and it outputs “Jun 18, 2024Amazon Games library”, so this is driving me crazy.