Tested three things here:
1. I made sure my change to calculating `ancestorThreads` from `ancestorThreadInfos` was a no-op:
```
const ancestorThreads1 = useSelector(state =>
ancestorThreadInfos(threadInfo.id)(state),
);
const ancestorThreads2 = useSelector(ancestorThreadInfos(threadInfo.id));
console.log(_isEqual(ancestorThreads, ancestorThreads1));
```
```
2. I compared the result arrays returned from the original code and the new code:
```
```
function useAncestorThreads(
threadInfo: ThreadInfo,
): $ReadOnlyArray<ThreadInfo> {
// This is the original code on `master`
const currentResult = useSelector(state => {
if (!threadIsPending(threadInfo.id)) {
const ancestorThreads = ancestorThreadInfos(threadInfo.id)(state);
if (ancestorThreads.length > 1) {
return ancestorThreads.slice(0, -1);
}
return ancestorThreads;
}
const genesisThreadInfo = threadInfoSelector(state)[genesis.id];
return genesisThreadInfo ? [genesisThreadInfo] : [];
});
// This is the new code provided in this diff
const ancestorThreads1 = useSelector(ancestorThreadInfos(threadInfo.id));
const genesisThreadInfo1 = useSelector(
state => threadInfoSelector(state)[genesis.id],
);
const newResult = React.useMemo(() => {
if (!threadIsPending(threadInfo.id)) {
return ancestorThreads1.length > 1
? ancestorThreads1.slice(0, -1)
: ancestorThreads1;
}
return genesisThreadInfo1 ? [genesisThreadInfo1] : [];
}, [ancestorThreads1, genesisThreadInfo1, threadInfo.id]);
console.log('current vs. new result: ', _isEqual(currentResult, newResult));
return newResult;
}
```
3. I went through the app and made sure I didn't notice any regressions from this