Understanding specifications with regard to current draw of components NL17SZ08, 6N137 and 74HC165 and other current-related questions
Under normal circumstances, devices are not operated beyond rated conditiond. Under fault conditions, those may be exceeded but immediate damage is avoided if conditions are limited below absolute maximum ratings.
AND gate: consumption is 10uA. More current will flow on supply pins if the chip is driving a load or clamping voltage, and max current it tolerates is 100mA.
Optocoupler: no max current won't be 40mA. It tolerates a surge of 200mA for a short 100us period defined in the datasheet, but long term average absolute max is 20mA. Recommended rated current is max 15mA which means under normal conditions. High level supply max current means how much the supply current is consumed by the coupler at most when data output is high, not driving a load, and it has nothing to do with the LED.
Shift register: When the chip is abused under abnormal conditions again like overvoltage or shortcircuit or too much load, it does not get permanent damage if supply pin current stays below 50mA. The chip really itself consumes max 160 uA under extreme conditions, and will consume the extra current for each input that is held at indeterminate voltage level between logic high and low, which again is not valid input to the chip and should never happen.