https://arduino.stackexchange.com/a/26899:
The MCP23017 (and it's sister the SPI-based MCP23S17) can have their
interrupt pins set to "mirror" mode. In this mode both pins are
internally joined so when an interrupt occurs on any port both pins
activate. This is done using the MIRROR
bit of the IOCON
register. Using this will turn your 4 interrupt pins into just 2, one for each Arduino INT pin.
Should you want to add more in the future, or if you find you want to
use one of the interrupt pins on the Arduino for something else, there
is also the ODR
bit in the IOCON
register. This sets the interrupt pins to be open drain,
which means that all of them can be wired together into just one INT
pin on the Arduino. Add a pullup (or enable the internal pullup) and you
have have many IO expanders on one INT pin. Of course, that then means
that you have to poll all the expanders to find which of them triggered
the interrupt, so could slow things down somewhat depending on how you
are using it.
https://stackoverflow.com/questions/65862346/problems-with-esp32-interrupts-connected-to-mcp23017