javascript code does not execute for authenticated users


Maybe someone of you has already encountered this weird problem that I am having. I have javascript code that runs fine when you are an anonymous user and no longer works when authenticating. The library is loaded, but the code does not execute. Does this speak to anyone?
My drupal version is 8.9.2 and the code in question :

(function ($, Drupal) {
Drupal.behaviors.toto = {
attach(context, settings) {
  $('.block--toto ul', context).once('toto-behavior').each(function() {

      let toto = $('.block--toto ul');
    let istotoActive = toto.find('li.is-active');

    toto
      .wrap('<div class="dropdown"></div>')
      .closest('.dropdown')
      .prepend('<button href="#toto" class="dropdown-toggle" data-toggle="dropdown">' + istotoActive.attr('hreflang') + '</button>');

    toto
      .addClass('dropdown-menu')
      .find('li').addClass('dropdown-item')
      .find('a').addClass('dropdown-link');
    $('.block--toto li').each(function () {
      $(this).on('click', function () {
        $(this).closest('.dropdown')
          .find('.dropdown-toggle').text($(this).text())
      })
    })

  });
}

};
})(jQuery, Drupal);

Thanks for help