It is important to consider what Taiwan gets out of this. Some temporary diplomatic publicity? US and European lawmakers have been visiting regularly of late, and Pelosi's visit makes sense in that context, but this one is more sensitive for Beijing because she is the Speaker of the House and it appears like a very large salami slice of the one China policy.
If the PRC overreacts and we have a third Taiwan Strait Crisis on our hands, that could result in some unpleasant surprises for Taiwan. The PLA is capable of much more than it was back in 1996-97.
That said, the optics of Pelosi nixing the trip would be poor. There would be no way it could be spun as anything other than caving to Chinese threats.
In the future, the US should focus on supporting Taiwan in substantive ways that are not so overtly provocative without offering major benefits. Closer cooperation between the US and Taiwan militaries comes to mind, involving Japan to whatever degree possible, as does the US and Taiwan signing a bilateral trade agreement.