How exactly to do linear time quickselect with duplicate elements?

It’s well known that the quickselect algorithm, which runs in average case linear time, can be made linear time in the worst case as well, by using the median of medians strategy to select the pivot. This also allows us to implement quicksort in guaranteed O(n \log n) time.

While median-of-medians is theoretically interesting, it is not of much use in the real world. For sorting, the introsort approach with median-of-three partitioning is more suitable. Median-of-three partitioning has low overhead, and unlikely to degenerate to quadratic time behaviour except in the case of unusual adversarial sequences. On those rare occasions when the recursion gets too deep, introsort switches from quicksort to heapsort. Median-of-medians partitioning has too much overhead compared to heapsort to actually be useful. For selection, libstdc++ pursues a similar approach, namely median-of-three partitioning and switching from quickselect to heapselect if the recursion gets too deep; this implies that the selection may take O(n \log n) time in rare situations, which is unlikely to cause any practical issues. Interestingly, libc++‘s std::nth_element implementation simply degenerates to quadratic time when given a median-of-three killer sequence as input (Musser, 1997). Presumably, few people complain since such sequences rarely occur in practice, and this is perfectly kosher according to the C++ standard, which merely requires linear time performance on average.

Why might one be interested in worst-case linear time quickselect despite the fact that it’s not useful enough to have made it into the two most widely used and respected C++ standard library implementations? The main reason I can think of is that you might, at some point, be applying for a job, and you might get an annoying interviewer who will dock marks from you if you don’t write a solution that has asymptotically optimal worst-case performance. You might say to yourself, I wouldn’t want to work for a company with this kind of interview process anyway. If that’s the case, I suppose there’s no compelling reason for you to read the rest of this post, other than curiosity.

When all elements are distinct, quickselect with median-of-medians is not hard to implement. The particular way in which the partitioning loop is implemented is immaterial, since there is only a single correct result. For example, we might use the simple Lomuto partitioning procedure given in CLRS. However, the version in CLRS takes the rightmost element of the range as the pivot, and CLRS itself remarks that the procedure needs to be modified to take an explicit pivot element in order to be usable with the median of medians. Of course, we can simply swap this element with the rightmost element and proceed with the original procedure:

// let x = *pivot; then, after this call, [begin, result) <= x && *result == x && (result, end) > x
template <std::random_access_iterator It>
It partition(It begin, It pivot, It end) {
    using std::ranges::iter_swap;
    iter_swap(pivot, end - 1);
    It result = begin;
    for (It i = begin; i < end - 1; i++) {
        if (*i <= end[-1]) {  // NB: end[-1] is where the pivot value is right now
            iter_swap(i, result);
    iter_swap(result, end - 1);
    return result;

(This code requires some additional concepts beyond std::random_access_iterator, and should probably be rangified. This is left as an exercise for the reader.)

The full quickselect may look something like this:

template <std::random_access_iterator It>
void nth_element(It begin, It nth, It end) {
    const auto N = end - begin;
    if (N <= 5) {
        // insertion sort
        for (auto i = begin; i < end; i++) {
            const auto dest = std::upper_bound(begin, i, *i);
            std::rotate(dest, i, i + 1);
    for (int i = 0; i + 5 <= N; i += 5) {
        // move the median of this block of 5 into the middle of the block
        nth_element(begin + i, begin + (i + 2), begin + (i + 5));
        // move the median to the beginning of the array
        std::ranges::iter_swap(begin + (i / 5), begin + i + 2);
    nth_element(begin, begin + (N / 10), begin + (N / 5));
    const auto m = partition(begin, begin + (N / 10), end);
    if (nth < m) {
        nth_element(begin, nth, m);
    } else if (nth > m) {
        nth_element(m, nth, end);
    // if nth == m: nothing to do

Before we address the issue of duplicate elements, we should review the reason why this algorithm runs in guaranteed linear time. Let T(n) denote the worst-case running time of quickselect with median-of-medians partitioning, run on an array with n elements. There are approximately n/5 groups of 5. The median of medians is greater than half of these medians (constituting approximately n/10 elements). Each of those medians is greater than two elements in its group of 5; thus, the median of medians is greater than approximately 3n/10 elements. By the same token, the median of medians is less than approximately 3n/10 elements. It therefore follows that the side of the partition we descend into has size at most approximately 7n/10. The time to compute the median of medians itself is T(\lceil n/5\rceil) + O(n), and the partitioning step is of course linear. Thus

\displaystyle T(n) = T(n/5 + O(1)) + T(7n/10 + O(1)) + \Theta(n)

where we have used O(1) to make our use of approximately precise, since e.g., \lceil n/5 \rceil = n/5 + O(1). Now, because n/5 + 7n/10 is strictly less than n, it follows that T(n) = \Theta(n). A careful proof can be found in CLRS; you can also use the Akra–Bazzi theorem, which has the advantage that it lets us also easily answer the question of what happens if the two factors of 1/5 and 7/10 were replaced by factors whose sum is exactly 1, or strictly greater than 1. As you can probably guess, the answers would be T(n) = \Theta(n \log n) and T(n) = \Theta(n^p), respectively, where p is a constant greater than 1.

With the partitioning procedure given above, we can immediately see that there will be a problem if duplicate elements are present. In particular, if all elements in the array are equal, the right half of the partition will always be empty, leaving us to recurse into the left half which has N - 1 elements. In fact, because there is only one possible partition value, it doesn’t matter how we select that value; the running time will be at least quadratic, and the recursive nature of the median-of-medians computation actually results in superpolynomial time. It’s therefore clear that we must change the way we partition.

Indeed, the poor behaviour of Lomuto partitioning in an array where all (or almost all) elements are equal is a pretty good reason not to use it, even in the sorting case where we can switch to heapsort after a certain point. This switch-over would happen after k \log n recursive calls for some constant k, meaning that by that time, \Theta(n \log n) operations have already been done, and nearly all of the array remains unsorted. It would be better, even for introsort, to use a partitioning procedure that behaves well in the presence of many duplicates. This is typically the Hoare partitioning procedure or a variant:

// let x be the initial value of *pivot and k the return value; then,
// [begin, k) <= x and [k, end) >= x
template <std::random_access_iterator It>
It partition(It begin, It pivot, It end) {
    using std::ranges::iter_swap;
    iter_swap(begin, pivot);
    It i = begin;
    It j = end;
    while (true) {
        do {
        } while (*j > *pivot);
        while (*i < *pivot) {
        if (i < j) {
            iter_swap(i, j);
        } else {
            return j + 1;

The Hoare partitioning procedure is more complex than Lomuto; it’s not immediately obvious, upon reading the code, that it’s even correct at all (this is an exercise in CLRS; solutions can be found online). Lomuto thus has pedagogical value, whereas Hoare is used in practice. In the case of all elements distinct, Lomuto generally performs many unnecessary swaps, since the kth element less than the pivot (in index order) will always get swapped into position k, even if its original position was fine (i.e., to the left of the pivot’s final position); Hoare does not do this, as every swap it performs (except for the initial swap to move the pivot to the front, which is necessary in order to avoid degenerate partitions) will have the effect of exchanging an element that should be on the left and is on the right with an element that should be on the right and is on the left. In the presence of duplicates, Hoare can perform some unnecessary swaps of an element equal to the pivot and on the left with an element equal to the pivot and on ther right. However, Lomuto will also perform unnecessary swaps here, and indeed, when all elements are equal, Lomuto will perform about n/2 swaps compared to Hoare’s n/4.

A slight modification is needed to the nth_element implementation when using the two-way Hoare partitioning as shown above: the else branch must be made unconditional since the element at position m is not guaranteed to be in its final sorted position. With this change being made, our quickselect implementation should perform reasonably well in the presence of duplicates. But is it linear in the worst case?

The answer hinges on the issue of how lopsided a partition is possible in the presence of duplicates, where the pivot is chosen by median-of-medians partitioning. The case with all elements equal is actually a best case for Hoare partitioning; while it will perform unnecessary swaps, it will also move the left pointer in lockstep with the right pointer, meeting exactly in the middle. But what is a worst case? Well, if 3n/10 + 1 of the elements are zeroes, and 7n/10 - 1 are ones, and zero is chosen as the pivot (which is possible by gerrymandering), and the right pointer skips over all the ones at once and then moves in lockstep with the left, we’ll get a split where the left partition is about 3n/20 zeroes and the right partition has the remaining 17n/20 elements. Since 17/20 + 1/5 > 1, this is a sufficiently bad split to be problematic. However, this particular case isn’t actually possible, because in this case 0 wouldn’t be chosen as the partition anyway. If we gerrymander the array to make 0 the median of medians, but otherwise move the ones as far to the right as possible, it looks like 00011 00011 00011 … 11111 11111 11111 …, and Hoare partitioning will yield a 3:13 split in this case. Still, 13/16 + 1/5 = 81/80, greater than 1 by just a hair. Wait a second though—even this exact case is not possible, because we have written our quickselect above so that the n/5 medians all get moved to become the first n/5 elements of the array before the partitioning step is actually run. And even if a split worse than 1:4 can still happen, it’s not clear whether we can engineer the input so that the split is sufficiently bad upon every iteration, as the array gets reordered and whittled down, to yield superlinear running time. I don’t have an answer here; Hoare partitioning is difficult to analyze.

So what do we do? Well, you might feel that our algorithm by this point probably runs in worst-case linear time, and even if it doesn’t, it runs in O(n^{1+c}) time where c is some small constant. But, as I said, you may be applying for a job where the interviewer wants you to write something that has provably worst-case linear time performance. In that case, it might occur to you that we need to be smart about how we handle elements that are equal to the pivot. (Duplicates that are unequal to the pivot are not a problem, since it is clear which half of the array they will end up in after partitioning.)

The solution to this problem is three-way partitioning: we must modify our approach so that the partitioning procedure is guaranteed to place all values equal to the pivot in their sorted positions. Writing such a partitioning loop is known as the Dutch national flag problem. There are various possible solutions; this one is based on (Dijkstra, 1976):

// returns the range of elements equal to the pivot.
// pivot is a value, not an iterator.
template <std::random_access_iterator It>
auto partition(It begin, It end, const auto& pivot) {
     using std::ranges::iter_swap;
     auto i = begin, j = begin, k = end;
     while (j < k) {
         const auto c = (*j <=> pivot);
         if (c == std::weak_ordering::less) {
             iter_swap(j++, i++);
         } else if (c == std::weak_ordering::greater) {
             iter_swap(j, --k);
         } else {
     return std::ranges::subrange(i, j);

Why does this help? Well, the reasoning for why the median of medians is greater than at least (3/10 - \epsilon)n elements when all elements are distinct carries over easily to the non-distinct case, but the inequality becomes non-strict: the median of medians is greater than or equal to at least (3/10 - \epsilon)n elements and likewise less than or equal to at least (3/10 - \epsilon)n elements. This implies that when the three-way partition is run on a range with n elements, the returned range at least overlaps with the middle two-fifths of the array; this is a generalization of the case with all elements distinct, where the returned iterator would always fall within the middle two-fifths of the array. We amend the calling code thus:

const auto r = partition(begin, end, begin[N / 10]);
if (nth < r.begin()) {
    nth_element(begin, nth, r.begin());
} else if (nth >= r.end()) {
    nth_element(r.end(), nth, end);
// nth falls within r: nothing to do

Now, in each case where nth_element is recursively called, it cannot be with more than 7n/10 elements, since that would require the equal range to fall entirely within the 3n/10 elements at the other end, which cannot happen.

I haven’t measured the performance of the overall algorithm, but it’s clear that it suffers from more overhead than the case with all elements distinct (using Hoare partitioning) since, as with Lomuto partitioning, we may perform unnecessary swaps, wherein an element that is already in the correct region of the array (according to whether it is less than, equal to, or greater than the pivot value) is nevertheless moved to a different location. This overhead is incurred even if it turns out that there are no duplicates in the array after all. The overhead is made significantly greater if we do not have three-way comparisons available (or if we do not make use of them), as each element is then potentially subjected to two full comparisons: one to determine whether it is less than the pivot, and (if the answer is no) a subsequent one to determine whether it is equal. Such is the cost of writing a guaranteed linear time quickselect. It’s not hard to see why, in the real world, the libstdc++ approach is preferred: select the pivot using median-of-3, run Hoare partitioning (which will usually perform well in the presence of duplicates despite not checking for them explicitly), and then switch over to heapselect in the very rare cases where this fails to behave well.

Posted in Uncategorized | Leave a comment

More updates on immigrant visa spillover (why I don’t think 60,000 extra green cards will materialize)

In a previous post I discussed how a large number of family-based preference immigrant visas will not be used up by the end of the fiscal year and the unused visas will be added to the employment-based quota in the new fiscal year starting in October 2020 (next month), resulting in at least 200,000 employment-based green cards being available. I’m now convinced, however, that unless Trump loses the election, the vast majority of the extra green cards are not likely to be issued. And even if Biden takes over in January, he will likely have too much on his plate to prevent the visa wastage that Trump will set the system up for.

There are two specific mechanisms by which this visa wastage will occur. The first is the use of processing delays. USCIS announced that, while they had averted the furlough of 70% of their employees that was planned for August 30, there will be increased wait times across the board. Many observers don’t believe that USCIS had a genuine funding crisis in the first place—they manufactured it as cover for delaying the issuance of immigration benefits in general. And there have already been significant delays, as Charlie Oppenheim had indicated in a previous check-in that the EB quota would most likely not be hit in FY 2020. In other words, USCIS will not even issue an extra 16,253 EB green cards that are available in FY 2020 (total quota 156,253), so it seems foolish to expect them to use up the 60,000+ extra green cards that will be available in FY 2021. I’m not even sure if they’re going to issue the base number of 140,000 EB green cards in FY 2021.

The processing delays excuse is almost bulletproof. It may be that a House committee will eventually call Cuccinelli or Edlow to testify about the processing delays, but this is not likely to yield any relief as he can just reiterate the existing talking points regarding the delays and answer I don’t know regarding any specifics. The inquiry will end there; the House may be able to subpoena documents, but any real oversight can only be accomplished by forcing USCIS to generate detailed reports, which can only be done through legislation, not through a subpoena; and that will not happen as long as the Senate remains under Republican control. At risk of stating the obvious, the House also can’t pass any legislation by itself to force USCIS to speed up adjudications. One also shouldn’t pin any hopes on the other avenue for relief—namely, the courts—as the whole judicial process may take too long to and fail to prevent the visas from going wasted at the end of September 2021. This is particularly the case if the Supreme Court gets involved. So we find ourselves in a situation where there is ample motivation for the Trump administration to cause delays (for example, a recent Breitbart article encouraged him to do so in order to supposedly protect American workers) and little that can be done to stop them.

The other visa wastage mechanism is more obscure. It revolves around the question: how does the spillover actually get calculated and allocated (practically speaking)? The answer is as follows. Early in the fiscal year, the State Department estimates the quota for that fiscal year (in other words, they estimate the number of visas that have spilled over from the previous year, and add that to the base quota). In FY 2020, these estimates were published at some point in late October 2019 or early November (I don’t know the exact date). However, the September 2020 visa bulletin contains the following note:

The State Department is required to make the determination of the worldwide numerical limitations, as outlined in Section 201(c) and (d) of the INA, on an annual basis. These calculations are based in part on data provided by U.S. Citizen and Immigration Services (USCIS) regarding the number of immediate relative adjustments in the preceding year and the number of aliens paroled into the United States under Section 212(d)(5) in the second preceding year. Without this information, it is impossible to make an official determination of the annual limits. To avoid delays in processing while waiting for the USCIS data, the Visa Office (VO) bases allocations on the minimum annual limits outlined in Section 201 of the INA. On July 31st, USCIS provided the required data to VO.

In other words, it’s not until the final quarter of the fiscal year that USCIS transmits to DOS the data required to finalize the computation of the quotas. Until DOS receives that report from USCIS, they will simply assume that only the base quota (140,000 EB visas) will be available in that year, and move the cutoff dates accordingly. This implies that only at the very end of the year is USCIS able to approve more applicants using the spillover visas, based on the cutoff date advancements that were made possible by the spillover.

One might wonder why USCIS takes so long to provide the data. Is that also Trump’s fault? Interestingly, the answer is probably not. If you browse older visa bulletins from when Obama was in office, you see something similar—USCIS doesn’t send the report until July. This works fine in a typical year, when the amount of spillover visas is low. For example, the Sep 2016 visa bulletin gives the finalized EB quota for FY 2016 as 140,338, meaning that USCIS only then had to process 338 more EB adjustments in the last 2 months of the year than they would otherwise have had to. But in FY 2021, it’s simply not possible for USCIS to approve 60,000 extra applicants in the last 2 months (considering that in a normal year, only 35,000 applicants would be approved per quarter) regardless of who occupies the White House.

USCIS and DOS can work together to prevent the wastage by changing their procedures to accommodate the unprecedented amount of spillover in FY 2021. All they have to do is estimate very conservatively at the beginning of the fiscal year the number of extra EB visas; DOS can move the dates by taking into account those extra visas, and USCIS can approve them, and then in the last two months, the final number will be known and remaining visas can be issued (perhaps a small number more or less than was estimated to be available for those months). However, under the Trump administration, this isn’t likely to happen. It’s simply too easy for USCIS and DOS to just do what they’ve always done—knowing full well that it will lead to wastage—and pretend that the outcome couldn’t have been averted. Actively changing their procedures, even just a bit, in order to satisfy the Congressional mandate to use up all the visas would be seen as a massive giveaway to job-stealers like me.

As I mentioned before, I think that even if Biden takes over in January, it’s not likely that he’ll immediately take the necessary actions to prevent the visa wastage from unfolding. This doesn’t mean nothing will change if Democrats are elected; if Democrats can win the Senate as well as the Presidency, they could potentially increase both the EB and FB quotas for future years (and eliminate per-country caps). Trump staying in power, on the other hand, is unlikely (in my opinion) to be beneficial for EB immigrants the way that people sometimes think. Of course, I’m happy to be proven wrong—if lots of EB green cards get approved next year, it’ll be great to see them not go to waste and I’ll admit that some immigrants did benefit from Trump from Trump after all (while maintaining that it should not have been legal for Trump to use 212(f) to enact this travel ban in the first place).

Posted in Uncategorized | 1 Comment

Update on immigrant visa spillover

I previously wrote a post about the prospect of spillover of unused FB immigrant visas due to Trump’s immigrant visa ban to the EB quota. A lot of the information in that post was not accurate but I now have a better understanding of the situation so I am writing this update.

In a recent webinar with IIUSA (read a summary here), Charlie Oppenheim estimated that in FY 2021 (starting Oct 1, 2020), there will be at least 200,000 EB green cards available. That is, at least 60,000 out of the 226,000 FB visas available in FY 2020 will not be issued before the end of FY 2020, therefore, they will be added to the FY 2021 EB quota. This is good news for backlogged EB applicants, although some users on Trackitt have been asserting that the spillover would be sufficient to move the EB2 India date ahead several years, and that doesn’t seem to be correct. (But I’ll address this issue later in this post.)

I previously wrote that I wasn’t sure whether any spillover was going to happen at all—aren’t there enough applicants already inside the US to consume the FB numbers that cannot be used by applicants abroad? There had been speculation that the State Department was cooking the books in order to avoid issuing visas that they are legally required to issue. However, in the IIUSA webinar, Charlie explained that even the EB numbers will likely not be used up this year because of limited USCIS processing capacity. This suggests to me that the State Department has not been cooking the books in order to favour EB applicants over FB applicants. It is just that there is not enough processing capacity to use up the visas in either category. (Some people still, after all this time, think that Trump likes skilled immigrants. At this point, I don’t think there’s anything I can say to convince them that they’re wrong.)

One might wonder whether the unused EB visas this fiscal year will spill over to FB. The answer is sort of, but no. I claimed in my previous post that any unused EB visas will spill over to FB, and if they are still not used in FB the next year then they will spill over to EB again, and so on until the visas are used. It was pointed out to me that this could not possibly be true, because if it were true then it would have been possible to issue many more EB visas than have been issued to date. I looked into the issue a bit more, and it turns out that Congress wrote the EB to FB spillover rule in a way that makes it nearly impossible for FB to actually get any extra visas. The reason for this is that the FB quota is calculated using the formula MAX(226000, 480000 – IR + SO). Here, SO stands for the number of unused EB visas from the previous fiscal year, and IR stands for the number of immediate relative visas used during the previous fiscal year. In recent years, IR has generally been approximately 500,000. Because of this, it’s unlikely for us to ever see a situation where 480,000 – IR + SO is greater than 226,000. So, if Trump finds some way to get away with wasting a large number of EB visas (up to ~200,000 or so), he can make those visas permanently disappear.

Will Trump waste lots of EB visas in FY 2021? Maybe, maybe not. If USCIS tries to do so without reasonable justification, then I believe they will be subject to a lawsuit (which they will lose). But if they are able to claim that they don’t have enough processing capacity to process the additional EB adjustments that people would like to file in FY 2021, then I guess they will be able to get away with not issuing the green cards. Whether they will have enough capacity depends on what they will do with FB applicants in FY 2021 (I will discuss this issue in the next paragraph).

As we know, in the June and July visa bulletins, the FB cutoff dates did not move at a greater-than-usual pace despite the large number of FB applicants inside the US. I now believe that I understand why—it is because by the time the immigrant visa ban was announced (end of April), there was no longer enough time left to give those visas to people inside the US before the end of the fiscal year. An I-485 usually takes more than 5 months to adjudicate, and due to the pandemic, USCIS has had less processing capacity than usual; therefore, even in May, if the FB cutoff dates had been significantly advanced, allowing many applicants in the US to file, then the vast majority of those additional I-485s filed in May would not be able to be approved before the end of the fiscal year. At that point, the unused FB numbers would spill over to EB, so those I-485s would no longer be able to be approved using the FY 2020 quota. However, in such cases, the I-485s remain pending, which would mean that the applicants would be able to receive EADs, and be eligible for continuances in immigration court, while waiting for an immigrant visa number to become available. Given Trump’s agenda about immigration, it is understandable that he did not want to allow this [1]. I am not sure whether it is actually legal for USCIS to refuse to accept I-485s in this manner. The statutory criterion for filing for adjustment is that an immigrant visa must be immediately available at the time of filing; if there are so many available visas for applicants inside the US, because they are not available for applicants outside the US, then what authority do DHS/DOS have to disallow those people from filing? Well, I guess the answer is that the opportunity to use the adjustment of status procedure is a discretionary benefit: it is an alternative to consular processing that DHS allows at its discretion. So, I guess maybe they can say that if they believe that allowing an applicant to file an I-485 would create a high risk of that I-485 to be pending for a long time due to retrogression, then they have discretion to not accept that filing in the first place despite the fact that visas appear available. I am not sure.

The immigrant visa ban was extended last week, so that it will now continue through December. This again puts the FB applicants who are inside the US in a bad situation—for the same reason why DOS/DHS didn’t advance the FB cutoff dates rapidly in the June and July bulletins, I guess they still won’t do so in August, because again, allowing a flood of filings in August would result in most of those filings still being pending at the end of December. If the immigrant visa ban were not extended beyond December, the result would be that the visas would become available to applicants outside the US again, which would mean that the extra filings from people inside the US would again be subject to retrogression (possibly for many years). So I think that’s why it’s not going to happen. I suppose that if Trump gets re-elected and he continues extending the EO in 6-month increments, then DOS/DHS may have cover to indefinitely continue refusing to advance the dates more rapidly (based on the theoretical prospect of the ban ending in 6 months), drastically reducing the total number of FB visas that are issued in the next few years. This is another devious strategy that I imagine Miller may have devised. I think Congress should try to prevent this by changing the spillover rules. One attempt to do so is found in the HEROES Act, which is pending before the Senate, but I have no idea whether it’s likely to pass.

One other issue that I want to discuss is the allocation of the spilled-over visas in the EB categories. I discussed this issue a bit in my previous post, but I took some time to look into the issue more closely. There are some rules in INA 202 (8 USC §1152) that govern how the extra visas should be allocated to backlogged countries. First, (a)(3) says that if, after limiting each country to 7% of the total number of FB and EB visas, there is not enough demand to use up all the preference visas, then the remaining visas can be issued beyond the 7% limitation. In other words, DOS can advance the cutoff dates for that country. If there are multiple backlogged countries with demand for visas that were unused by the rest of the world, then DOS should attempt to allocate the extra visas to those countries according to the following rule: if natives of that country receive X% of the FB visas and Y% of the EB visas, then they should try to make X and Y as close as possible. In a typical year that means 1.61 FB visas should be issued for every one EB visa, to natives of any particular country. If a backlogged country is above that ratio, then it should get extra EB visas while the extra FB visas should be allocated to other backlogged countries; if it is below the ratio, then it should get extra FB visas while the extra EB visas should be allocated to other backlogged countries. Since preference immigrants from Mexico and the Philippines are overwhelmingly family-based while preference immigrants from India and China are overwhelmingly employment-based, it follows that, contrary to popular belief, Mexico and the Philippines should actually receive priority over India and China for EB visas that are not used by the rest of the world.

Then there is paragraph (a)(5)(A): If, after limiting each country to 7% of the total number of FB and EB visas, there is not enough demand to use up all the visas in any of the five EB preference categories, then the remaining visas in that preference category can be issued beyond the 7% limitation. This basically reiterates that there should not be wasted visas in any single preference category as long as there is sufficient demand for those visas. Thus, even though Mexico and the Philippines should receive priority over India and China for unused EB visas, because of the fact that Mexico and the Philippines have no EB-1 or EB-2 backlog anyway, it follows that all the extra EB-1 and EB-2 visas will be issued to Indians and Chinese.

The most confusing paragraphs are (e)(3) and (a)(5)(B). (e)(3) is another balancing rule similar to (e)(1), but here we are balancing across EB preference levels rather than between FB and EB. That is, if (a)(5)(A) allows extra EB visas to be issued to natives of a particular country, then DOS should attempt to make R_1 … R_5 as close to each other as possible, where R_i is the fraction of the EB-i visas that are issued to natives of that particular country. However, it’s not clear to me exactly what single metric is supposed to be optimized here by the allocation. (a)(5)(B) is some sort of limitation on (e)(3) that I am totally unable to understand.

So, after looking at these paragraphs, I’ve concluded that I have absolutely no idea how to answer the following questions: when Rest of World does not use up all the EB1 and EB2 visas, how many EB1 visas go to China and how many go to India, and how many EB2 visas go to China and how many go to India? People seem to assume that whatever EB2 visas are not used by Rest of World should just all go to Indians since they have the earliest priority dates, and that whatever EB1 visas are not used by Rest of World should similarly go to Indians until the Indian cutoff date catches up with the Chinese cutoff date at which point the two should be advanced in lockstep. However, I don’t think this is what INA 202 requires, but I have no idea what INA 202 does require.

All I know is that in FY 2021, backlogged EB applicants will receive a massive spillover; 2/7 of the the spilled-over visas will be distributed to EB1, 2/7 to EB2, and 2/7 to EB3; and Rest of World will almost certainly not use up all the EB1 and EB2 visas, just as they have not done so for the past few years, and that means extra visas for India and China, according to some distribution that I cannot predict. Maybe if I have time, I’ll try to file a Freedom of Information request with the State Department to get a hold of any internal documents they have that explain how this works. But if it’s all inside Charlie’s head, then there won’t be any documents to release.

[1] Well, I guess it was probably Miller who made the decision. Actually, I have to wonder whether Miller was responsible for the timing of the ban. If it had been announced later, there would not be as many visas left to waste in the year. If it had been announced earlier, there would be more time to process adjustments, so there would be less of an excuse to waste visas. Miller probably knows more about US immigration law than I do, so if I could see how the end of April was a particularly devious time to issue the ban, he probably could have seen that too. But I digress.

Posted in Uncategorized | 5 Comments

Legal speculation about recent visa bans

I previously published an FAQ about President Trump’s immigrant visa ban and work visa ban. You can read it here. The detailed answers to the questions therein are given on my US immigration FAQ on GitHub and backed by authoritative sources and reasoning. But some people also have questions whose answers are of a more speculative nature. This blog post addresses those questions.

Q1: What does section 5(b) of the work visa ban mean?

A1: Section 5(b) refers to the requirements of the Immigration and Nationality Act that employers petitioning for a green card in the EB3 or EB2 categories (excepting National Interest Waiver applicants) must obtain a labor certification (LC/PERM) and employers petitioning for H-1B status must file an labor condition application (LCA).

For an LC to be approved, the employer must demonstrate that there are not sufficient workers who are able, willing, qualified, and available (thus necessitating the importation of a permanent foreign worker) and that the employment of the foreign worker will not adversely affect the wages and working conditions of similarly employed workers in the US. For an LCA to be approved, the employer must demonstrate that it is offering at least the prevailing wage and that the H-1B worker will be employed under working conditions that will not adversely affect the working conditions of other workers similarly employed. The Department of Labor shall determine, in both cases, whether the employer has met the burden of proof.

Thus, the meaning of section 5(b) of the proclamation is that Trump is not sure whether the existing LC/LCA process is sufficiently stringent to guarantee that the EB2/EB3/H-1B programs do not disadvantage US workers in violation of the INA and that he would like the Department of Labor and DHS to consider whether new, more stringent regulations should be promulgated governing the LC and LCA/I-129 processes.

Q2: If Trump does publish new LC/LCA regulations, can they be used to retroactively revoke green cards and H-1B status?

A2: Although the text does extend to aliens who have been admittedpursuant to an EB-2 or EB-3 immigrant visa, there is absolutely no chance that the courts will allow Trump to deport people who already have green cards just because he thinks that the previous regulations that allowed them to obtain a labor certification were not stringent enough, and I believe that Trump knows that, and he will not try to fight a battle that he cannot win.

In the case of H-1B workers, I think there is some legal argument that Trump could force some of them to leave if he believes that the LCA/I-129 process was not stringent enough, by ordering the Secretary of State to issue new regulations to revoke their visas under INA 221(i) and INA 237(a)(1)(B). I don’t expect him to actually do this, however, because it would be much easier to just deny extensions based on the new LCA/I-129 regulations. This would have a measurable effect of gradually reducing the number of H-1B workers in the US without going through protracted litigation related to the use of INA 221(i) and INA 237(a)(1)(B).

Q3: If Trump does publish new LC regulations, can he require I-485 applicants to undergo the new process prior to approval?

A3: If the regulation required aliens who had already submitted form I-485 (prior to the new regulations going into effect) to undergo recertification prior to I-485 approval, I think there’s about a 75% chance that such a provision would be illegal. Under AC21 106(c) (INA 204(j)/8 USC 1154(j)), an alien who has already filed an I-485 may, after 180 days have elapsed, switch to another job in the same occupation or a similar occupation without having to obtain a new labor certification. I think there’s a strong argument that if Congress has mandated that the alien can even take up a different job without a new labor market test, then the employer certainly cannot be required to perform a second labor market test for the same alien when it has already done so in the past. I don’t think such a requirement would be legal even if it contained an 180-day exemption. The reason for the 180-day waiting period is to merely ensure that the alien acted in good faith at the time of filing, and did not use that particular employer just so they could jump to another employer without redoing the green card process. If an alien whose I-485 had been pending for any length of time, whether greater or less than 180 days, were forced to undergo labor certification a second time prior to approval, I think that would violate the Congressional intent behind AC21.

Q4: If Trump does publish new LC regulations, can he use them to revoke I-140s that have already been approved, or require a new I-140 to be approved before proceeding to adjustment of status or immigrant visa processing?

A4: These questions seem to be closely related. I would guess that the courts would either allow both, or allow neither. I am not familiar enough with the Administrative Procedure Act, the applicable jurisprudence regarding retroactive application of regulations, and so on to even venture a vague guess as to whether the courts could strike down such regulations on those grounds. I did, however, find one news article in which an immigration lawyer argues that such regulations would violate INA 212(a)(5)(A) and AC21.

Q5: How is Trump’s proposal to allocate H-1B visas based on salary going to work?

A5: It has been reported that Trump wants to scrap the H-1B lottery and replace it with a system where the visas are allocated based on highest salary. No details of the plan have been released yet. The administration has not even said whether the system would attempt to normalize salary according to the geographical location and the occupation. (If such normalization is not done, then almost all of the visas would go to tech companies in Silicon Valley, Seattle, and NYC; other regions and industries, which also need H-1B workers, would not be able to compete.) In any case, regardless of how the system works, it is not clear whether it would be legal. The INA does not allow the limited pool of H-1B visas to be distributed based on salary; it simply specifies that once the quota runs out for a given fiscal year, no more aliens can be issued H-1B visas or H-1B status during that fiscal year. Thus, in the past, employers who did not file an H-1B petition early enough would not be able to import their desired candidate until the new quota became available for the following fiscal year, since all the visas would have been consumed already. Eventually, it got to the point where the number of petitions that were filed within the first week of the filing window was already enough to use up the entire quota for the year, so a random lottery system was introduced. One can justify the lottery as follows: It would be sort of silly if one petition that was delivered in the mail to USCIS on April 1st, 1 hour before another petition, received precedence on that basis. So instead, USCIS will take all petitions received in the first week of the filing window, and process them according to the legal fiction that some of them are randomly determined to have arrived earlier than others. If the Trump administration instead decided that the petitions with higher salary should be considered to have arrived earlier than others, he would be essentially introducing an adjudicative criterion that has no basis in the INA, so the courts probably would not allow this change, but I am not totally sure.

Q6: How likely is it that litigation against the immigrant visa ban and the work visa ban will succeed?

A6: In the immigrant visa ban case, the argument is essentially that Congress intended for a certain number of immigrant visas to be available per year in each category for family reunification, employment, and diversity, and that Trump should not be allowed to unilaterally reduce those numbers to zero using INA 212(f). My personal opinion is that the Supreme Court will let him get away with it based on the same reasoning as in the Trump v. Hawaii case, but that is just my personal speculation, and many actual lawyers disagree. In the work visa ban case, there are similar arguments, but there is also an additional argument that the ban violates the General Agreement on Trade in Services (GATS). The relationship between GATS and H-1B and L-1 visas is discussed here. However, it is not clear whether GATS is binding as a matter of domestic law. This issue is way beyond my depth, so I can’t really estimate the probability of this legal argument working, other than to say that it’s greater than zero.

Q7: What happened to Trump’s proposal to raise the fees for H-1B petitions to $20,000?

A7: The existence of such a proposal is merely speculative. Trump has not indicated that he plans on taking such an action. If he did attempt to do so, it could be argued that it would violate GATS (see previous Q/A). It could also be argued to be subverting Congressional intent of allowing the visas to be issued. (For example, if Trump made the fee $10 million, then it would obviously be an attempt to indirectly ban the approval of H-1B petitions, so the courts would not allow that. Whether they would allow a $20,000 fee is not totally clear, but I’m leaning toward no. On the other hand, a small fee increase would be completely legal, since Trump could argue that its purpose is to allow USCIS to recover the costs associated with whatever extreme vetting he wants them to do.)

Q8: What happened to Trump’s proposal to ban H-1B extensions for jobs that pay level 1 wages?

A8: Again, the existence of such a proposal, to not grant H-1B extensions for workers being paid level 1 wages unless their employer offered at least level 2 wages in the extension petition, is merely speculative. I think there’s about a 90% chance that such a regulation would be illegal, if it were to be published. Congress has set the criteria for aliens to obtain H-1B status, and the executive branch is responsible for devising a process, and promulgating regulations, to determine whether aliens seeking H-1B status meet those criteria. The executive has wide latitude in doing so, but may not invent new regulatory criteria out of thin air that are unrelated to the statutory criteria set by Congress. If Trump finds that allowing H-1B workers to remain at level 1 wages in a particular area, for a particular occupation, adversely affects US workers in that occupation in that area, then perhaps it would be within his authority to order the Department of Labor to not approve such extensions for that particular occupation, in that particular geographical area, pursuant to INA 212(n)(1)(A). But I think the statute requires such a determination to be made individually with respect to each occupation and each geographical area; Trump cannot thus issue a blanket finding with respect to level 1 wages across all areas and occupations.

Q9: Is Trump still planning to rescind the H-4 EAD rule?

A9: No word on that, but probably.

Q10: What about the proposed changes to the OPT program?

A10: There has been speculation that Trump is planning to eliminate or shorten the STEM OPT extension, or to limit it to particular sectors, or to limit it to students who graduate at the top of their class. Since the STEM OPT extension was created purely by regulation, and not statute, these changes would be fully within Trump’s authority to enact. However, until he actually publishes the regulations, we won’t know whether he is going to do it at all, and if so, what the provisions are.

Q11: Could Trump stop issuing EADs to individuals with pending Adjustment of Status applications, thus eliminating the employment authorization of tens of thousands of aliens who are in the backlog waiting for a green card?

A11: Yes, that’s a regulatory change that would be within his authority to enact, since the AOS EAD was created by regulation in 1981 and not by statute. The notice in the Federal Register explained that these individuals will receive unrestricted employment authorization soon anyway (since they will have a green card), so that it made sense for INS to grant some such individuals (who might not otherwise have a means of obtaining employment authorization for supporting themselves in the US) an EAD at its own discretion. But Trump could very well argue that such discretion should generally not be exercised favourably due to the current unemployment crisis, and use that as a justification for eliminating the AOS EAD at least temporarily (though, as the Supreme Court’s recent DACA decision indicated, he would at least need to consider reliance interests as part of the rulemaking process). Despite the fact that Trump could very well do this, I currently don’t expect him to. Even the speculations based on supposed leaks of would be in the work visa ban did not suggest that Trump was considering such an action.

Posted in Uncategorized | Leave a comment

Comments about today’s DACA ruling

Today, the Supreme Court issued a 5–4 ruling that the Trump administration’s rescission of the DACA program was unlawful. The opinion of the Court was delivered by Roberts, with Ginsburg, Breyer, and Kagan joining in full, and Sotomayor concurring as to the result. You can read the ruling here.

Last year, I correctly predicted how the justices would vote. Now it’s time to give some further comments about the ruling.

First, the Court did not rule on whether DACA is actually legal. In fact, the Court held that Attorney General’s finding that DACA is illegal provides a justification for rescinding the associated benefits such as work authorization (but not the grant of deferred action itself). However, DHS still must consider reliance interests before promulgating the rescission of benefits. DHS also did not provide adequate justification for the rescission of the entire program, as there had not been a finding of illegality of the deferred action itself.

Second, the Court did not rule that DACA rescission needs to go through the notice-and-comment rulemaking procedure. In fact, it noted that such claims were already raised in the lower courts and rejected there. For example, the 9th circuit concluded in DHS v. Regents of UC that both the creation of DACA, and its rescission, are general statements of policy and are thus exempt from notice-and-comment. This fact is very important, because notice-and-comment requires at least a 30 day period for the public to submit comments, and the agency is required to review every single comment and address the substantive subject matter of those comments in its rulemaking. In practice, this is usually done by categorizing the comments according to their key points and responding to each point identified, as obviously, it would not be practical to provide a response to each comment separately. Still, given that a hypothetical notice of proposed rulemaking regarding DACA would likely attract hundreds of thousands of public comments, it would take DHS several months to review and categorize all the comments. Because the Court ruled that this procedure is not required, DHS could potentially move much faster.

Third, the Court also did not specify the detailed requirements that a rescission would need to satisfy in order to be lawful. It notes that DHS should consider reliance interests in determining how the wind-down should be performed—for example, in considering the reliance interests, DHS could have decided on a longer transition period or provided for case-by-case discretion. But after balancing all relevant considerations, DHS is not required to arrive at any particular conclusion.

Fourth, as the Court did not rule today on whether DACA is legal or not, I believe that if an entity had standing to challenge DACA itself, arguing that it’s unconstitutional for the executive branch to grant deferred action in such a form and that the plaintiff were injured by this action, then there’s still some possibility that the Court could make such a ruling in the future. The kind of entity with the strongest claim to standing would be a State, as in the United States v. Texas case regarding DAPA and the DACA expansion. I don’t think it’s likely that a State will actually mount such a challenge against DACA, because even a majority of Republicans support DACA now. But there could potentially be other entities with standing, such as workers alleging that DACA unlawfully increases competition for jobs (cf. the Save Jobs USA lawsuit regarding the H-4 EAD program).

Where does this leave us? Basically, it means DHS could issue a new memo rescinding DACA, but they must provide sufficient justifications for both the rescission of the deferred action itself and the associated benefits. DHS could potentially act quickly to issue a new memo, in which it makes a finding, based on law, that it lacks the authority to grant deferred action, and, after considering reliance interests and other relevant considerations, determines that DHS will end DACA. But what form would that take?

DHS could move to immediately end the DACA program and revoke all existing EADs granted under it, rendering all current DACA beneficiaries potentially subject to immediate deportation and making it illegal for their current employers to keep them on the payroll.

Or, DHS could announce that they will stop accepting new applications and renewals after some transition period (maybe 6 months, maybe more, maybe less). In that case, some grants of deferred action would begin to expire within 6 months (as one can renew up to 6 months in advance of expiration), which gets us almost to the end of Trump’s term. In that case, if Biden wins the election in November, the damage done to DACA will have been minimal.

Between the two options, I think the latter is much more likely. This is for two reasons. First, the former option would make the administration more vulnerable to further legal challenges based on allegations that the rationale provided was not sufficient to justify such extreme action (notwithstanding the fact that the administration might ultimately prevail in that case). Second, by taking the latter option, Trump can emphasize that he’s doing as much as he can to fulfill his promise of enforcing the immigration laws, but his efforts will prove futile unless he is elected to a second term. This would be a smart political strategy for him.

In conclusion, if you support DACA, then be sure to do your part in getting Biden elected in November and flipping the Senate. (While non-citizens cannot vote and cannot legally spend money on or donate for the purpose of electioneering communications, we can still do our part in raising awareness and advocating for what we believe in.) If Trump is re-elected, then not only does he have more than enough time to end DACA legally, but he could also potentially replace Justice Ginsburg, without whom today’s ruling would not have been possible. If Trump loses but the GOP manages to keep 51 seats in the Senate, then Mitch McConnell will block any efforts at immigration reform and the future of DACA recipients will remain uncertain. There would also be a small risk that SCOTUS would revisit DACA and end it for good, over the objections of the Biden administration. In that case, the administration could still do a lot to delay deportations, but would be enjoined from issuing work permits, which would severely limit the options for DACA people to support themselves.

Posted in Uncategorized | Leave a comment

How does immigrant visa spillover work?

Update (June 27, 2020): Some of the information in this post is inaccurate. See this newer post for corrections and clarifications.

There has been some recent speculation that 52,000 visas could spill over from the family-based quota to the employment-based quota due to Trump’s recent executive order to ban immigrants from entering the US for 60 days (which many people believe will be extended, perhaps until the election or even longer). There have been many arguments about the mechanics of spillover on Trackitt, an immigration forum largely populated by Indian people, who face very long backlogs for employment-based immigrant visas. However, the law is quite clear, so much of the controversy seems unnecessary.

Where did the 52,000 figure come from?

The figure of 52,000 comes from a tweet by the Migration Policy Institute that 26,000 green cards would be blocked by the EO during each month it remains in effect, which means 52,000 over a period of 60 days. The MPI doesn’t explain their methodology, but I think we can draw some inferences.

The MPI seems to have gotten the 26,000 figure by taking the total of 315,403 and dividing by 12. This total includes family-based, employment-based, and diversity visas. So we can immediately conclude that MPI did not estimate 52,000 family-based immigrants would be blocked. That was, rather, their total estimate across all three categories. Rather, their estimate is that 5,565 immediate relative immigrants and 15,409 family-based preference immigrants would be blocked per month.

Second, the MPI’s figures look very similar to the official State Department figures for immigrant visas issued abroad in 2019. For example, the MPI’s estimate of 3,432 for EB-2 is very close to the State Department figure of 3,497 EB-2 immigrant visas issued in 2019, which is substantially less than the actual annual EB-2 quota of roughly 40,000. From this we can infer that the MPI numbers mean something like we estimate that 52,000 people who would have received immigrant visas over the next 60 days, now will not as a result of the EO.

This does not mean that 52,000 visas will go unused! Since the EO does not block green cards for applicants who are already in the US, there is a possibility that some or all of those 52,000 visas can be issued to applicants in the US, instead of the people outside the US who would have received them if not for the EO. (Note: An applicant in the US who receives a green card consumes an immigrant visa, but is not actually physically issued a visa.) The MPI figures simply do not answer the question of whether any immigrant visas will be unused this year.

Will any family-based visas actually go unused this year?

The May 2020 visa bulletin was released on April 24, several days later than expected, since it could not be cleared for release until Trump’s executive order had been finalized. However, astute readers noticed that the date April 6, 2020 was printed at the bottom of the bulletin, suggesting that the cutoff dates had already been calculated by then. Indeed, the movement in cutoff dates was, perhaps, no more than would have been expected without the EO. For example, the F3 and F4 Mexico cutoff dates, which advanced 1 month in the April bulletin, again advanced 1 month in the May bulletin.

Now, in order to use up all the family-based visas for this fiscal year, the State Department must move the cutoff dates far enough ahead so that enough people are able to apply for their visas. Since most family-based applicants live outside the US, and many of them can no longer receive a visa due to the EO, it is necessary to move the cutoff dates more quickly so the visas can instead be used by applicants inside the US. The fact that this does not seem to have happened has made some immigration lawyers concerned. However, until the June 2020 visa bulletin is released, it’s too early to panic—again, the May 2020 cutoff dates may simply not have taken into account the EO yet. (Update (June 27, 2020): It looks like they decided not to move the dates rapidly. See the newer post linked at the top of this post for a possible explanation of why.)

Most family-based immigrants on the waiting list are outside the US. This is because most of them cannot easily obtain a long-term visa, such as a student visa or work visa, that would enable them to live in the US while they wait for an immigrant visa to become available. This fact has led some to speculate whether there are just not enough of them inside the US to use up the rest of the family-based immigration quota for the current fiscal year. For example, if, hypothetically speaking (I am just pulling numbers out of thin air here), 120,000 of the 226,000 family-based immigrant visas this year had already been issued, and there were 85,000 remaining applicants waiting inside the US, then at least 21,000 visas would go unused. However, I don’t think that this is the case. (Update (June 27, 2020): Since they decided not to move the dates rapidly, this paragraph is moot. Most of the applicants inside the US will not receive a green card this year even though green cards should be available to them. See the newer post linked at the top of this post.)

Greg Siskind, an immigration lawyer, has made the following comment that most casual readers won’t understand: They could have moved all the Mexican categories to May 2001 (they’re backed up to the 90s except F2A) so that the 245i folks in the US could file adjustments to fill in the gap from IV processing abroad. Siskind is referring to INA 245(i), which, in short, allows certain people with priority dates earlier than May 2001 to obtain a green card even if they are currently residing in the US without authorization. In other words, if the State Department is having a hard time issuing all the remaining family-based visas this year, they should advance the Mexico cutoff dates, possibly all the way up to May 2001, to give more people a chance to apply, as there is probably a substantial population of Mexicans inside the US who may be eligible for green cards under INA 245(i). The number of such individuals is impossible to determine accurately, so the State Department cannot in good faith say well, we tried to issue all the visas available, but we couldn’t do so because of the EO unless they’ve given all the 245(i) folks an opportunity to apply. (Update (June 27, 2020): Looks like this paragraph is wrong—they are not allowing these people to apply, most likely because any application filed in May or later could not be approved by the end of September anyway. See the newer post linked at the top of this post.)

Some immigration lawyers think that the administration is going to try to waste family-based visas on purpose as part of their agenda to curtail immigration. If the June 2020 visa bulletin rolls around and it really does seem that they are not making an effort to advance the dates, then it is likely that immigrant advocate groups will have some members of Congress ask the State Department why they are not on track to issue all the visas to eligible applicants—and there may be legal challenges if the answer is not satisfactory. So I believe that while some family-based visas may go unused this year, the chances of the number being significantly affected by the EO are slim (i.e., there is a slim chance that any judicial relief gets held up until after the end of the fiscal year). (We should note that there was already some spillover into the employment-based quota this year, indicating that not all of last year’s family-based visas were used. Nobody seems to know exactly why, so the same might happen this year, EO or no EO.) (Update (June 27, 2020): Looks like I was wrong; a massive number of FB green cards will go unused this year. See the newer post linked at the top of this post.)

If some visas are unused, would they actually spill over?

According to INA 201(d)(1)(B), if the full quota of family-based visas is not used up in this fiscal year, then the unused numbers are added to next year’s employment-based immigration quota. While Trump can suspend issuance of visas pursuant to INA 212(f), he is without power to block the spillover provisions. Even if Trump takes further actions to block issuance of employment-based green cards next year, in an effort to prevent immigrants from benefitting from the spillover, he cannot actually waste any green cards. If the spilled-over numbers, added to the employment-based quota next year, are not used, they will just spill over as family-based quota the following year, and so on indefinitely back and forth between the two categories until either Trump is out of office, or Congress changes the law. (Update (June 27, 2020): This is wrong. If the visas spill over from FB to EB, but then they are not used in EB, then they will actually be lost. See the newer post linked at the top of this post.)

Unused diversity visa numbers, however, do not spill over. They are neither added to next year’s diversity visa quota, or to any other category.

If visas spill over to employment-based immigrants, how will they be allocated?

INA 201(d)(1)(B) prescribes the worldwide level of employment-based immigrants. INA 203(b) prescribes that the worldwide level shall be allocated as follows: 2/7 to EB-1, 2/7 to EB-2, 2/7 to EB-3, 1/14 to EB-4, and 1/14 to EB-5. Some people have speculated that the spillover visas will all go to the most backlogged people, namely Indian-born EB-2 applicants; this is false. Some have speculated that the spillover visas will all go to EB-1; this is also false. The EB-2 and EB-3 quotas will increase proportionally. This is very clear from the statute; there is no ambiguity. Some have speculated that none of the spillover numbers can be allocated to Indians because the number of available visas for natives of any single country is fixed. This is also false, since the 7% limitation applies to the total worldwide level of preference-based immigrants according to INA 202(a)(2), which, as previously mentioned, is not a fixed number but, according to INA 201, depends on how many visas spilled over from the previous year.

Thus, if any numbers spill over, then the State Department will allocate them the same way they would have allocated the usual quota—just with all the numbers scaled up proportionally. Because EB-1 Rest of World is unlikely to use up all the numbers (whether there is spillover or no spillover), that means that the spilled-over visas allocated to EB-1 (namely 2/7 of the total) will mostly go to the most backlogged (i.e., Indian-born applicants) due to INA 202(a)(5). Another 2/7 would spill over to EB-2, which would also be allocated in the usual way, but if Rest of World does not use up all the EB-2 numbers, then any additional numbers would again be allocated to India. In EB-3, demand from Rest of World exceeds supply, so if current patterns continue, then EB-3 China and EB-3 India would likely only receive 7% of any spilled-over numbers. (Update (June 27, 2020): I’m not sure whether the most backlogged rule is correct. So I don’t know how the extra EB-1 and EB-2 visas will be divided between China and India. See the newer post linked at the top of this post.)


It’s not likely that there will be any unused family-based visas to spill over. But if there are any unused family-based visas, they will spill over to employment-based immigrants and Trump cannot prevent that. If such spillover does occur, then it will be distributed evenly to EB-1, EB-2, and EB-3, and within each preference level, Rest of World will still be entitled to 86% of the spilled-over visas, which will only go to India if there are not enough Rest of World applicants. Thus, spillover could significantly benefit EB-1 India and EB- 3 Rest of World, whereas EB-3 India and all three Chinese categories would likely receive little benefit (though EB-5 is another story). The EB-2 Rest of World and EB-2 India situations are harder to predict (although EB-2 India is so backlogged that even if it does end up receiving additional unused numbers from EB-2 Rest of World, the movement will still not be that much). (Update (June 27, 2020): I’m not sure whether this is correct anymore; EB1 and EB2 China may receive more visas than I expected, but the truth is that I just don’t know. See the newer post linked at the top of this post.)

Posted in Uncategorized | 2 Comments

Armchair lawyering about the recent EO

The Attorney General of New York is making preparations to challenge Trump’s executive order banning most immigrants from entering the US “temporarily” under INA 212(f) (8 USC §1182(f)). I am sure there are various other groups also interested in filing legal challenges.

The order can be found here.

Can the President ban all immigration?

Some commentators suggest that INA 212(f) doesn’t give the President authority to end all immigration. Here, all has been placed in quotation marks since the EO does not ban all immigration anyway; certain categories such as spouses of US citizens are exempted. The idea is that bans based on 212(f) that are too broad may not be allowable.

Yet, the text clearly says the President may suspend the entry of all aliens or any class of aliens.

Some argue that, while the Trump v. Hawaii case established that the President may ban all aliens from particular countries, that it would be contrary to the INA for the President to indefinitely end the issuance of visas in entire preference categories – for example, as Trump is banning all F4 immigrants (brothers and sisters of US citizens) from entering the US (unless they qualify for an exemption based on being in the US already) this could be argued to contravene an imagined intent of Congress in enacting INA 201 and INA 203 of making at least 65,000 F4 immigrant visas available each fiscal year.

This argument is essentially about timing: it is clear from the statute that the President may ban all aliens, but the argument is that this power could not be used to establish a ban of such duration that it would result in the visas allocated by Congress going wasted. I don’t think this argument is convincing. The statute does say the President can suspend entry for such period as he shall deem necessary, which is pretty close to explicitly saying there’s no limit on the President’s discretion to set the duration of the suspension.

Is Trump’s use of INA 212(f) an unconstitutional delegation?

Congress is not constitutionally permitted to delegate its legislative power to the executive branch or any other entity, but may enact statutes that enable the executive branch to exercise discretion over policy, if it provides an intelligible principle. For example, in INA 212(a)(9)(B), Congress banned aliens from entering the United States if they were unlawfully present for more than 180 days, but granted the Attorney General discretion to waive this inadmissibility in certain cases if it would cause extreme hardship to a US citizen or LPR relative. In this case, the executive is permitted to set policy regarding which aliens can receive waivers, but Congress provided the guiding principle that the standard of eligibility for such waiver must be based on a level of extreme hardship.

A recent case in the United States District Court for the District of Oregon concerned whether Trump’s use of INA 212(f) to bar the entry of aliens who could not demonstrate that they would be able to obtain certain types of health insurance coverage (Case No. 3:19-cv-1743-SI). The plaintiffs in this case argued that this use of INA 212(f) involved an unconstitutional delegation. The court agreed and granted a preliminary injunction.

The court’s opinion stated that INA 212(f) is overbroad in delegation, providing no intelligible principle for the Presidents exercise of discretion, since the only condition is that the President must find that the entry of aliens would be detrimental to the interests of the United States. The court thus found that Congress cannot delegate power to the President in this manner. The defendants pointed out that Supreme Court precedent (Knauff v. Shaughnessy, 338 US 537 (1950)) established that the President’s inherent constitutional power over foreign affairs includes the power to restrict the entry of aliens (so that INA 212(f) confers little or no additional power upon the President but merely reaffirms power that the President already possesses). The district court’s opinion, however, was that such inherent power of the President over immigration does not extend to restricting immigration for domestic policy purposes (in contrast to e.g. national security or foreign relations concerns).

In my opinion, this type of argument, if it is raised in the cases concerning the present executive order, would not be likely to persuade the Supreme Court. I believe the Supreme Court would almost certainly find that the President’s inherent authority to restrict the entry of aliens is not limited only to situations implicate national security or foreign relations concerns.


Based on what we know about the current Supreme Court, I think it’s overwhelmingly unlikely that they would strike down the recent EO. In fact, I think it’s very likely that they would quickly reverse any stay of the EO issued by a lower court. I think it’s almost irresponsible for the mainstream media to give false hope to immigrants that a court challenge would be likely to succeed. Then again, there are actual legal experts who disagree with me, so take this with a grain of salt.

Posted in Uncategorized | Leave a comment

Why Chinese people should support HR1044/S386

In discourse about HR1044/S386, there is a myth that Chinese people don’t support removing the per-country caps. I can tell you that this is false. I’m Chinese and I support it.

Not only is it the right thing to do, but even for purely selfish reasons, I should still support it. Imagine if the per-country caps had never existed in the first place. There are two possible scenarios. One is that the waiting time for Chinese would be shorter than it is now, and I would already have a green card. That’s obviously a win. What about the other scenario? What if there were more applicants in the alternate universe, so waiting times were 5+ years for everyone, rather than 3–4 years for Chinese?

Well, I would rather live in that world—where everyone waits 5+ years—than in this one, where I’m disadvantaged by longer waiting times. Any factor that puts me at a disadvantage relative to other people threatens my well-being in a competitive globalized economy.

Right now, I have the opportunity to work for many of the top companies in the United States because they can sponsor me for H-1B status. However, there is no guarantee that this will continue to be the case. My bachelor’s degree is not in computer science, and I’ve already received two RFEs (in which USCIS asked my company’s lawyers to provide more evidence that I’m actually eligible for TN and H-1B status). The Trump administration has increased scrutiny on H-1B applications, and determined that junior software engineering positions should not be presumed to be eligible for the H-1B classification. The word on the streets is that scrutiny has increased for H-1B applicants who don’t have CS degrees, so I can expect this situation to persist in the near future. No one can predict the Trump administration’s next moves, and the probability that they will change the regulations so that I’m simply not eligible to be an H-1B software engineer anymore—either because I don’t have a CS degree, or because we just can’t prove that my job is complex enough to merit an H-1B—is non-negligible. Of course, if I already had a green card, then any such future changes wouldn’t affect me.

I live in constant fear that I am going to have to leave the United States while others (including hundreds of thousands of my fellow Canadian citizens) continue to work for top US companies, getting the best possible experience, and I fall behind. As I said: this disadvantage would threaten my well-being in a competitive globalized economy. As long as the opportunities available in tech continue to expand, everything will be fine and dandy; but if a recession were to occur, limiting the availability of decent software engineering jobs, I would be in the unenviable position of having to compete with people with much better résumés for that limited set of openings. Chances are that I’d be forced to accept some demoralizing, low-paid position in a company that treats its software engineers like cogs and has frequent layoffs. (Never forget that Dilbert is a minor exaggeration of the reality of working as a software engineer in a company where software engineers can’t command respect.)

Some people think I’m overly anxious. I would say that we software engineers should remember how lucky we are right now. Do you see how other people our age, who are just as intelligent and hard-working as we are, struggle for economic security? One might say, there but for the grace of God go we.

I have often expressed my desire for a world with open borders, but we all know that’s not happening any time soon. For the time being, people who were born in United States, or otherwise acquired US citizenship at birth or through the naturalization of a parent, have an advantage over me in terms of access to the best software engineering opportunities, which handicaps me in the competition for the sharply limited availability of economic security in a neoliberal globalized economy. The effect of the per-country cap system is to also put me at a disadvantage relative to equally qualified individuals born in Canada or, say, Australia, Hong Kong, Taiwan, or South Korea. For this reason, I must support HR1044/S386, and that would remain true even if I had the animosity against Indian software engineers that many anti-HR1044/S386 people seem to have.

Posted in Uncategorized | 2 Comments

INA 203(g) cancellation and DoL processing times

The Department of Labor is currently taking 4–5 months to process prevailing wage determination requests and 3–4 months to process permanent labor certifications. See here.

A few years ago, prevailing wage determinations only used to take about 6 weeks.

This increase in processing times has created an obscure possibility for me and other employment-based green card applicants to lose their place in line.

Because of my position in the queue, I’ll become eligible to apply for a green card in about 1.5 to 2 years from now. Once I become eligible, I have a 12 month deadline to file the final form (Form I-485) to apply for a green card. Due to INA 203(g) (8 USC §1153(g)), if I fail to file within this deadline, then I go to the back of the line and will probably have to wait another 3 years or so before I can file again.

Those of you who have gone through, or are going through the employment-based immigration process have probably already figured out why this is dangerous. For others, read on.

At the time of filing Form I-485, I have to have the intent to work for my sponsoring employer—the one that filed all the paperwork with the Department of Labor. Technically, I don’t have to be working for them when the form is filed, but they must be offering me either new or continuing employment in order for the I-485 to be approvable. So what happens if I’ve filed my I-485, it sits in a queue with USCIS for a few months, and then I get fired? The I-485 is effectively abandoned, and I have to find a new employer who has to file the same forms with the Department of Labor as the old employer did. And that’ll take another 7–9 months.

During that 7–9 month period, I won’t be able to file Form I-485. It will only be possible to file it after the DoL has approved all of the new employer’s paperwork. What this means is that while all this is happening, my 12 month clock may run out. Example: if Form I-485 has been pending for 5 months and my current employer fires me, then I have about 7 months left on the clock before USCIS says: hey, it’s been an entire year since the last time you applied for a green card even though you’ve been at the front of the line the whole time. So we’re sending you to the back of the line. See ya!

This analysis depends on a rather pessimistic interpretation of INA 203(g). In particular, you might wonder whether the 12 month clock should start over at the point at which I get fired, causing my I-485 to be abandoned. Let’s say this is the case. Then the 7–9 month processing time doesn’t seem as dangerous. But 3–5 months is not a lot of slack. It takes time to find a new job, to gather experience letters from previous co-workers, and for attorneys to draft the required forms. Furthermore, the Department of Labor sometimes randomly decides to audit permanent labor certification applications, adding an extra 3 months, in which case the total processing time becomes 10–12 months. In that case, it’s almost certain that the 12 month clock would run out during the time when paperwork is pending with DoL.

There is one safeguard against this possibility. If my I-485 has been pending for at least 180 days before I leave my employer, then the new employer doesn’t need to file any paperwork, so it’s all good. However, if I get fired within the first 180 days, then I’m possibly screwed. In the past, there would probably have been enough time to go through all the paperwork with the new employer. But given current processing times, there may not be.

Processing times are not likely to decrease in the next few years (particularly as I don’t especially trust the Democrats to nominate someone who can actually beat Trump in 2020), and the chances of Congress passing a fix to this situation—say, by extending the deadline in INA 203(g) from 12 months to 24 months—are virtually zero, because this issue is simply too obscure. If there is any legislative fix, it will have to come as part of a comprehensive immigration reform package—and don’t hold your breath for that either.

But hey, it’s not the end of the world. If it takes an extra 3 years to get my green card, at least I’m still working and getting paid during that time. Unless, of course, the Trump administration has made it virtually impossible to get H-1Bs by then. If that’s the case, I’d better hope to be married to an American by then…

Posted in Uncategorized | 1 Comment

On solving problems for a living

Back when I was just an intern, spending my summers chilling out in the bay area (and doing work sometimes), I started reading Quora and noticed people debating whether the compensation for software engineering was disproportionate to the difficulty of the job. (I have no idea how long this debate has been going on.) It seemed pretty obvious to me back then the answer was yes, or, at least, that the actual difficulty of software engineering is much less than people think when they haven’t been exposed to the right opportunities to learn programming. It seemed inevitable that salaries would eventually fall as a result of more people being trained to enter the field.

But I saw a contrary point of view being expressed in the answers sometimes, namely that software engineering is stressful. Some of that, of course, is due to factors that are not universal, such as long hours and on-call rotations. But it was argued that the job is also demanding in other ways, such as the need to constantly learn new technologies and new developments in existing technologies. At the time, I don’t think I had the perspective to be able to understand this.

Now that I’ve been a full-time software engineer for almost three years, I think I’m starting to understand. I’m lucky to be on a team where I’m nearly free from certain stressors that my software engineer friends have to deal with, such as pager duty, daily scrums, and frequent meetings in general. But I also experience job-related stress of a particular kind, and I suspect this experience may be close to universal: it’s that I don’t know what the next problem is that needs to be solved, but I know I’ll have to do everything I can to solve it.

Almost all jobs involve problem-solving to some extent, but occupy different positions on a spectrum. On one end of the spectrum are jobs that involve performing a bounded set of responsibilities in some fixed way, such as working in a call centre where you just follow a script and transfer the caller to a specialist whenever that fails. Those jobs can often be extremely stressful due to the long hours, low pay, and general working conditions, but not due to the nature of the problems to be solved. Many jobs fall somewhere near the middle of the spectrum, consisting mostly of fixed responsibilities with some variability in challenges and some room to invent ideas for how to better perform those responsibilities. I would argue that software engineering stands at the far end of the spectrum, together with other traditionally highly compensated jobs such as that of the doctor or lawyer. For while a lecturer can present the same lecture twice to different audiences and a bus driver can drive along the same route twice on different days, a software engineer should not even write the same ten lines of code twice, or perform the same operations twice—they should be factoring out the code into reusable components and automating the operations.

It follows that if you still have a job as a software engineer, it is only because you are needed in order to deal with a never-ending stream of new problems that are qualitatively different from the ones you have solved before. And that means you have to constantly search for solutions to those problems. You cannot follow a fixed set of steps to try to solve the problems you are faced with, and claim that your responsibilities have been fulfilled. You have to apply your technical and creative skills to their fullest extent.

As I said, this makes software engineering comparable to practising medicine or law. Your job is not to apply some fixed set of techniques but to treat the patient or to win the case (or perhaps settle it favourably, yeah, yeah, I know) and you go to school for a long time so you can learn the knowledge needed to prepare a solution to the problem from first principles as it may be different in significant ways from cases that you have dealt with in the past. Being constantly challenged in this way is very likely to be stressful, particularly when you aren’t sure whether the problem even has a solution, or how you should feel about your own personal inability to solve it.

So I think when people argue that software engineers are disproportionately compensated, they should consider that people whose jobs consist of this kind of generalized problem solving within a broad domain do tend to be well-compensated and that this should not be unexpected when you consider the demands of those jobs (and I hardly hear anyone saying doctors are overpaid).

I wonder whether there are highly compensated jobs that are much closer to the other end of the spectrum, where you do more or less the same thing every day but you get paid a lot of money to do it. I suspect that a job of that type would be very desirable and that it could only continue to be well-compensated if it either had artificial barriers to entry or required skills that are difficult to acquire. If jobs in the former category existed in the past, they have probably mostly disappeared due to globalization and other forces eliminating such barriers. But perhaps there are jobs that fall into the second category.

Posted in Uncategorized | 2 Comments