(address token, uint256 id) = IVaultRegistry(registry).vaultToToken(_vault);
if (id == 0) revert NotVault(_vault);
// Reverts if buyout state is not inactive
(, , State current, , , ) = IBuyout(buyout).buyoutInfo(_vault);
State required = State.INACTIVE;
if (current != required) revert IBuyout.InvalidState(required, current);
function testLeaveBuyoutStarted() public {
    initializeMigration(alice, bob, TOTAL_SUPPLY, HALF_SUPPLY, true);
    (nftReceiverSelectors, nftReceiverPlugins) = initializeNFTReceiver();
    // Migrate to a vault with no permissions (just to test out migration)
    address[] memory modules = new address[](1);
    modules[0] = address(mockModule);
    // Bob makes the proposal
    bob.migrationModule.propose(
        vault,
        modules,
        nftReceiverPlugins,
        nftReceiverSelectors,
        TOTAL_SUPPLY * 2,
        1 ether
    );
    // Bob joins the proposal
    bob.migrationModule.join{value: 0.5 ether}(vault, 1, HALF_SUPPLY);

    // Alice started buyout
    alice.buyoutModule.start{value: 1 ether}(vault);
    (, , State current, , , ) = alice.buyoutModule.buyoutInfo(vault);
    assert(current == State.LIVE);

    vm.expectRevert(
        abi.encodeWithSelector(IBuyout.InvalidState.selector, 0, 1)
    );
    // Bob cannot leave
    bob.migrationModule.leave(vault, 1);
}

function testLeaveBuyoutSuccess() public {
    // Send Bob a smaller amount so Alice can win the auction
    initializeMigration(alice, bob, TOTAL_SUPPLY, HALF_SUPPLY/2, true);
    (nftReceiverSelectors, nftReceiverPlugins) = initializeNFTReceiver();
    // Migrate to a vault with no permissions (just to test out migration)
    address[] memory modules = new address[](1);
    modules[0] = address(mockModule);
    // Bob makes the proposal
    bob.migrationModule.propose(
        vault,
        modules,
        nftReceiverPlugins,
        nftReceiverSelectors,
        TOTAL_SUPPLY * 2,
        1 ether
    );
    // Bob joins the proposal
    bob.migrationModule.join{value: 0.5 ether}(vault, 1, HALF_SUPPLY/2);

    // Alice did a buyout
    alice.buyoutModule.start{value: 1 ether}(vault);
    vm.warp(rejectionPeriod + 1);
    alice.buyoutModule.end(vault, burnProof);

    (, , State current, , , ) = alice.buyoutModule.buyoutInfo(vault);
    assert(current == State.SUCCESS);

    vm.expectRevert(
        abi.encodeWithSelector(IBuyout.InvalidState.selector, 0, 2)
    );
    // Bob cannot leave
    bob.migrationModule.leave(vault, 1);
}
mapping(address => uint256) public latestCommit;

function commit(address _vault, uint256 _proposalId) {
    ...
    if (currentPrice > proposal.targetPrice) {
        ...
        latestCommit[_vault] = _proposalId;
    }
}
(, address proposer, State current, , , ) = IBuyout(buyout).buyoutInfo(_vault);

// if buyout is started by this proposal, check that state is inactive. Else allow leaving.
if (proposer == address(this) && latestCommit[_vault] == _proposalId) {
    State required = State.INACTIVE;
    if (current != required) revert IBuyout.InvalidState(required, current);
}
(, address proposer, State current, , , ) = IBuyout(buyout).buyoutInfo(_vault);

// if buyout is started by this proposal, check that state is inactive. Else allow withdrawing.
if (proposer == address(this) && latestCommit[_vault] == _proposalId) {
    State required = State.INACTIVE;
    if (current != required) revert IBuyout.InvalidState(required, current);
}
if (
    migrationInfo[_vault][_proposalId].newVault != address(0)
) revert NoContributionToWithdraw();
