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('');

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

    $('.block--toto li').each(function () {
      $(this).on('click', function () {


})(jQuery, Drupal);

Thanks for help