If you modified the TableOfContents shadow tiddler (e.g., to use your own "root tag"), then you might be able to bypass the problem by using Safe Mode (
http://tiddlywiki.com/#SafeMode) to load the file with the default shadow TableOfContents, so that TiddlerA and TiddlerB won't be in the tree, avoiding the infinite recursion.
Another method that might work:
First, drop the 'broken' document on a fresh empty.html and import all tiddlers except for TiddlerB. Next, edit TiddlerA and remove the tag for TiddlerB. Then, you can safely import TiddlerB without it causing the infinite recursion.