FIX: Don't show the Later This Week option in date pickers on Sundays

FIX: Don’t show the Later This Week option in date pickers on Sundays

diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
index ae2e97b..37212d5 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-selector-test.js
@@ -209,6 +209,34 @@ discourseModule(
       },
     });
 
+    componentTest("doesn't show 'Later This Week' on Sundays", {
+      /* We need this test to avoid regressions.
+      We tend to write such conditions and think that
+      they mean the beginning of business week
+      (Monday, Tuesday and Wednesday in this specific case):
+
+       if (date.day < 3) {
+           ...
+       }
+
+      In fact, Sunday will pass this check too, because
+      in moment.js 0 stands for Sunday. */
+
+      template: hbs`{{future-date-input-selector}}`,
+
+      beforeEach() {
+        const timezone = moment.tz.guess();
+        this.clock = fakeTime("2100-04-25 18:00:00", timezone, true); // Sunday evening
+      },
+
+      async test(assert) {
+        await this.subject.expand();
+        const options = getOptions();
+        const laterThisWeek = I18n.t("topic.auto_update_input.later_this_week");
+        assert.not(options.includes(laterThisWeek));
+      },
+    });
+
     componentTest("doesn't show 'Next Month' on the last day of the month", {
       template: hbs`{{future-date-input-selector}}`,
 
diff --git a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
index cfd208b..b163c48 100644
--- a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
+++ b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
@@ -40,7 +40,7 @@ export const TIMEFRAMES = [
   buildTimeframe({
     id: "later_this_week",
     format: "ddd, h a",
-    enabled: (opts) => !opts.canScheduleToday && opts.day < 4,
+    enabled: (opts) => !opts.canScheduleToday && opts.day > 0 && opts.day < 4,
     when: (time, timeOfDay) => time.add(2, "day").hour(timeOfDay).minute(0),
   }),
   buildTimeframe({

GitHub sha: 814781780d6df699ee0a72e5a8224a96468c6ea1

This commit appears in #13839 which was approved by tgxworld. It was merged by tgxworld.