For example, a few years ago I removed a rather large 3rd party mathematics library because we were only using it for a single mathematical function that was very easy to replicate.
Remember, 3rd party libraries need to:
1: Be periodically audited to make sure you are in compliance with the license terms, and preferences of your company.
(1.5: This becomes important during an acquisition as someone will always come around doing due diligence.)
2: Be periodically updated (in case of security bugs)
2.5: Be updated on short notice when a security issue is revealed.
In the case of the mathematics library, replacing it with roughly 20 lines of code and 100 lines of tests is a significantly better tradeoff than constantly reviewing it every time one of the above things happens.
Now, at what point is it "worth it" to use the 3rd party library? In our case we'd need to make much heavier use of the library, probably at least 20 different mathematical functions from it.