code: function getAddedDmUsersIfNecessary(preferences) {
      return (dispatch, getState) => {
          const userIds = [];
  
          for (const preference of preferences) {
              if (preference.category === Preferences.CATEGORY_DIRECT_CHANNEL_SHOW && preference.value === 'true') {
                  userIds.push(preference.name);
              }
          }
  
          if (userIds.length === 0) {
              return;
          }
  
          const state = getState();
          const profiles = getUsers(state);
          const statuses = getUserStatuses(state);
          const currentUserId = getCurrentUserId(state);
  
          const needProfiles = [];
          const needStatuses = [];
  
          for (const userId of userIds) {
              if (!profiles[userId] && userId !== currentUserId) {
                  needProfiles.push(userId);
              }
  
              if (statuses[userId] !== General.ONLINE) {
                  needStatuses.push(userId);
              }
          }
  
          if (needProfiles.length > 0) {
              dispatch(getProfilesByIds(needProfiles));
          }
  
          if (needStatuses.length > 0) {
              dispatch(getStatusesByIds(needStatuses));
          }
      };
  }
docs: Helpers