New Year Chaos JavaScript, needs to be sped up
Reduce the inner loops iteration count.
The problem is the inner loop is looping over too many items. The result is that you spend too much time processing data you know is irrelevant.
As the function should exit if it detects a position has made over 2 bribes, you need only have the inner loop check positions down 2 from the item you are checking, and not from the start of the line.
Quicker solution
It only requires a slight modification of your code, but as you have complicated the situation by calling an inner function sort the example has just removed the inner function.
The line for (j = pos-2; j &lt; i; j++) { is where the improvement is with pos being item[i] in your function.
function minBribe(queue) {
    var bribes = 0, i, j;
    for (i = 0; i &lt; queue.length; i++) {
        const pos = queue[i], at = i + 1;
        if (pos - at &gt; 2) { return &quot;Too chaotic&quot; } 
        for (j = Math.max(0, pos - 2); j &lt; i; j++) {
            if (queue[j] &gt; pos) { bribes++ }
        }
    } 
    return bribes;
}

This brings the solution down from \$O(n^2)\$ to near \$O(n)\$ however the number of bribes is a factor so its closer to \$O(n + (m^{0.5}/2))\$ where \$m\$ is the number of bribes. (this is only an approximation)